@mathdoy/toggle-querystring

1.1.0 • Public • Published

Toggle Query String

Toggle Restify library for toggle

Installation

$ npm install --save @mathdoy/toggle @mathdoy/toggle-querystring
import { createToggle } from "@mathdoy/toggle";
import { createToggleQuerystring } from "@mathdoy/toggle-querystring";

// ...

const toggleQuerystring = createToggleQuerystring({
  // Query string parameter
  param: "features",
  // Default features
  features: {
    logo: true,
  },
});

const toggle = createToggle({
  features: toggleQuerystring(window.location.search),
});

// toggleQuerystring("?features[foo]=1&features[bar]&features[qaz]=false")
// {
//     logo: true,
//     foo: true,
//     bar: true,
//     qaz: false
// }

// toggleQuerystring("?features[logo]=false")
// { logo: false } // default has been overriden

See a full example in toggle/blob/master/examples/react/src/index.js

For more information on toggle

For more information on toggle see toggle

Using it with react

$ npm install --save @mathdoy/toggle @mathdoy/toggle-querystring @mathdoy/toggle-react

See more information for toggle-react

License

Toggle is licensed under the MIT License.

Package Sidebar

Install

npm i @mathdoy/toggle-querystring

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

5.39 kB

Total Files

5

Last publish

Collaborators

  • mathdoy-user