Giter Site home page Giter Site logo

turls's Introduction

Turls

๐Ÿข A simple JavaScript utility for conditionally query string together.



About โ€ข Getting started โ€ข Authors โ€ข Acknowledgements โ€ข License


๐Ÿง About

Turls is a simple, JavaScript utility for conditionally query string together. The idea behind Turls is to prevent developers from rewriting the same code in multiple places, while also making it easy to dynamically construct advanced queries that can be easily shared across multiple files.

Turls is perfect for applications that need to dynamically query an API or database, but it can also be used as a general purpose URL builder.

๐Ÿ Getting Started

  1. Install with npm, yarn or pnpm:
npm install turls
yarn add turls
pnpm add turls
  1. Use the library:
// ESM
import turls from 'turls';
turls("https://api.example.com/", "query", {
  "id=1": true,
  "name=John Doe": true,
  "age=30": true
})
// => "https://api.example.com/query?id=1&name=John%20Doe&age=30"

// CommonJS
const turls = require('turls');
turls("https://api.example.com/", "query", {
  "id=1": true,
  "name=John Doe": true,
  "age=30": true
})
// => "https://api.example.com/query?id=1&name=John%20Doe&age=30"

๐Ÿš€ Usage

turls("https://api.example.com/", "query");
// => "https://api.example.com/query"

turls("https://api.example.com/", "query", "search");
// => "https://api.example.com/querysearch"

turls("https://api.example.com/", "query", {
  "id=1": true,
  "name=John Doe": true,
  "age=30": true
})
// => "https://api.example.com/query?id=1&name=John%20Doe&age=30"

turls("https://api.example.com/", "query", {
  "id=1": true,
  "name=John Doe": true,
  "age=30": false
})
// => "https://api.example.com/query?id=1&name=John%20Doe"

turls("https://api.example.com/", "query", {
  "id=1": false,
  "name=John Doe": true,
  "age=30": false,
})
// => "https://api.example.com/query?name=John%20Doe"

โœ๏ธ Authors

๐ŸŽ‰ Acknowledgements

ยฉ License

  • MIT License

turls's People

Contributors

hiyudev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.