Comparing version 2.1.0 to 2.2.0
@@ -0,1 +1,7 @@ | ||
## v2.2.0 (2017-05-23) | ||
* Add helper methods | ||
- `buildPath()` | ||
## v2.1.0 (2017-05-18) | ||
@@ -2,0 +8,0 @@ |
@@ -41,4 +41,8 @@ /** | ||
/** | ||
* Build path from Tokens like array | ||
*/ | ||
export declare const buildPath: (tokens: (string | number)[]) => string; | ||
/** | ||
* Check contains of wildcard syntax | ||
*/ | ||
export declare const containWildcardToken: (path: string) => boolean; |
@@ -397,4 +397,8 @@ "use strict"; | ||
/** | ||
* Build path from Tokens like array | ||
*/ | ||
exports.buildPath = function (tokens) { return (tokens.map(function (token) { return exports.escapePath("" + token); }).join('.')); }; | ||
/** | ||
* Check contains of wildcard syntax | ||
*/ | ||
exports.containWildcardToken = function (path) { return (!isString(path) ? false : exports.tokenize(path).some(function (p) { return p === '*'; })); }; | ||
exports.containWildcardToken = function (path) { return (!isString(path) ? false : exports.tokenize(path).indexOf('*') > -1); }; |
{ | ||
"name": "dot-wild", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Use powerful dot notation (dot path + wildcard) to manipulate properties of JSON", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -1,3 +0,2 @@ | ||
dot-wild | ||
======== | ||
# dot-wild | ||
@@ -209,2 +208,12 @@ [![Build Status](http://img.shields.io/travis/tsuyoshiwada/dot-wild.svg?style=flat-square)](https://travis-ci.org/tsuyoshiwada/dot-wild) | ||
/** | ||
* Build path from Tokens like array | ||
*/ | ||
dot.buildPath(['foo', 'bar', 'baz']); | ||
// => 'foo.bar.baz' | ||
dot.buildPath([1, '[2]', 3, '["foo"]', 'bar.baz']); | ||
// => '1.2.3.foo.bar\\.baz' | ||
/** | ||
* Check contains wildcard token | ||
@@ -236,4 +245,7 @@ */ | ||
* `map(data, path, iteratee): any[]` | ||
* `tokenize(path): string[]` | ||
* `matchPath(pathA, pathB): boolean` | ||
* `escapePath(path): string` | ||
* `buildPath(tokens)[]): string` | ||
* `containWilcardToken(path): boolean` | ||
@@ -265,4 +277,11 @@ | ||
#### tokens | ||
**type: `(string | number)[]`** | ||
An array of tokens that make up the path. | ||
## Contribute | ||
@@ -283,1 +302,2 @@ | ||
[MIT © tsuyoshiwada](./LICENSE) | ||
@@ -525,2 +525,15 @@ import * as assert from 'power-assert'; | ||
it('buildPath()', () => { | ||
assert(dot.buildPath([]) === ''); | ||
assert(dot.buildPath(['foo']) === 'foo'); | ||
assert(dot.buildPath(['foo', 'bar', 'baz']) === 'foo.bar.baz'); | ||
assert(dot.buildPath(['foo.bar', 'baz']) === 'foo\\.bar.baz'); | ||
assert(dot.buildPath(['foo.bar.baz']) === 'foo\\.bar\\.baz'); | ||
assert(dot.buildPath([1, 2, 3]) === '1.2.3'); | ||
assert(dot.buildPath(['[1]', '[20]', '[300]']) === '1.20.300'); | ||
assert(dot.buildPath(['foo', '[\'bar\']', '["baz"]']) === 'foo.bar.baz'); | ||
assert(dot.buildPath(['foo', 1, 2, '[1]', '*', '["bar"]', 'baz.*']) === 'foo.1.2.1.*.bar.baz\\.*'); | ||
}); | ||
it('containWildcardToken()', () => { | ||
@@ -527,0 +540,0 @@ assert(dot.containWildcardToken('foo.*.bar')); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41332
905
300