0.0.9 • Published 2 years ago

turls v0.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

🐢 A simple JavaScript utility for conditionally query string together.


npm.io npm.io



🧐 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
0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago