Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tpkn/linkify-object
Converts object props into a link
https://github.com/tpkn/linkify-object
Last synced: about 2 months ago
JSON representation
Converts object props into a link
- Host: GitHub
- URL: https://github.com/tpkn/linkify-object
- Owner: tpkn
- License: mit
- Created: 2018-04-29T15:27:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-31T19:20:34.000Z (over 6 years ago)
- Last Synced: 2024-10-12T21:07:12.817Z (3 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# linkifyObject
Converts object props into a linkShort and quick module that converts object properties `{ a: b, c: d }` into a link `&a=b&c=d` and offers filter functionality. Was made for Express `request.queue` object. Works both in Node and web browsers (some of them).
## Installation
```bash
npm install linkify-object
```## API
### linkifyObject(object[, filter])
### object
Type: _Object_### filter
Type: _String_ | _Array_ | _Function_
Default: `true`
Helps to filter out props. Could be a `string`, a `string[]` or a `function`.## Usage
```javascript
const linkify = require('linkify-object');let obj = { a: 1, b: 2, c: 3, d: 4 };
linkify(obj, 'a');
// => 'b=2&c=3&d=4'linkify(obj, ['b', 'c']);
// => 'a=1&d=4'linkify(obj, item => /^(a|b|d)/.test(item));
// => 'c=3'
```## Changelog
#### v1.1.0 (2018-05-31):
- now it can stringify nested objects
- more advanced filter