Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/afeiship/next-param
Parse and stringify URL query strings for next.
https://github.com/afeiship/next-param
hash next param params qs query query-string
Last synced: 12 days ago
JSON representation
Parse and stringify URL query strings for next.
- Host: GitHub
- URL: https://github.com/afeiship/next-param
- Owner: afeiship
- License: mit
- Created: 2017-08-11T13:28:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-24T04:40:43.000Z (over 1 year ago)
- Last Synced: 2024-10-12T14:30:57.278Z (2 months ago)
- Topics: hash, next, param, params, qs, query, query-string
- Language: JavaScript
- Homepage:
- Size: 52.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# next-param
> Parse and stringify URL query strings for next.[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]## installation
```bash
npm install -S @jswork/next-param
```## apis
| name | type | description |
|---------|--------|----------------|
| hash | object | 传入的参数列表 |
| url | string | URL |
| options | object | 其它选项 |## options
| name | type | description |
|-----------|----------|----------------------------------------------------------------------|
| separator | string | 当参数值为 `array` 的时候, `join` 的连接字符 |
| encode | function | `encodeURI` 或者 `encodeURIComponent` ,或者自定义 |
| isEmpty | function | 过渡掉不需要的 `value` ,可以用这个函数;默认过滤掉 `null/undefined` |
| transform | function | 对每一组 `key/value` 进行处理,最终返回需要用 `&` 拼接的字符串 |## encode
- uri: 用 `encodeURIComponent` 对 value 进行 1次 `encode` 处理
- uri2: 用 `encodeURIComponent` 对 value 进行 2次 `encode` 处理
- base64: 对 value 用 `js-base64` 进行 `encode`## usage
```js
import '@jswork/next-param';nx.param({ var1: 123, var2: 'str', ids: [1,2,3] });
// var1=123&var2=str&ids=1%2C2%2C3
```## license
Code released under [the MIT license](https://github.com/afeiship/next-param/blob/master/LICENSE.txt).[version-image]: https://img.shields.io/npm/v/@jswork/next-param
[version-url]: https://npmjs.org/package/@jswork/next-param[license-image]: https://img.shields.io/npm/l/@jswork/next-param
[license-url]: https://github.com/afeiship/next-param/blob/master/LICENSE.txt[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-param
[size-url]: https://github.com/afeiship/next-param/blob/master/dist/next-param.min.js[download-image]: https://img.shields.io/npm/dm/@jswork/next-param
[download-url]: https://www.npmjs.com/package/@jswork/next-param