Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dot-wild

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dot-wild - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

8

CHANGELOG.md

@@ -0,1 +1,9 @@

## v2.0.0 (2017-04-25)
## Breaking changes
* Rechange collection helper callback arguments [#2](https://github.com/tsuyoshiwada/dot-wild/issues/2)
=> `(value: any, key: DotKey, context: any, path: string, data: any | any[])`
## v1.1.1 (2017-04-14)

@@ -2,0 +10,0 @@

4

lib/index.d.ts

@@ -22,3 +22,3 @@ export declare const get: (data: any, path: string | number, value?: any) => any;

*/
export declare const forEach: (data: any, path: string | number, iteratee: (value: any, key: string | number, path: string, data: any) => boolean | void) => void;
export declare const forEach: (data: any, path: string | number, iteratee: (value: any, key: string | number, context: any, path: string, data: any) => boolean | void) => void;
/**

@@ -28,3 +28,3 @@ * Create a new element

*/
export declare const map: (data: any, path: string | number, iteratee: (value: any, key: string | number, path: string, data: any) => any) => any[];
export declare const map: (data: any, path: string | number, iteratee: (value: any, key: string | number, context: any, path: string, data: any) => any) => any[];
/**

@@ -31,0 +31,0 @@ * Match key

@@ -104,3 +104,3 @@ "use strict";

wildcard: false,
values: [[value, []]],
values: [[value, data, []]],
};

@@ -113,3 +113,3 @@ }

index: 0,
context: (_a = {}, _a[key] = [[data, []]], _a),
context: (_a = {}, _a[key] = [[data, data, []]], _a),
wildcard: false,

@@ -120,3 +120,3 @@ };

each(state.context[key], function (_a) {
var item = _a[0], p = _a[1];
var item = _a[0], _ = _a[1], p = _a[2];
each(item, function (v, k) {

@@ -128,3 +128,3 @@ if (!matchToken(k, token))

}
next.push([v, p.concat([k])]);
next.push([v, item, p.concat([k])]);
});

@@ -142,3 +142,3 @@ });

wildcard: state.wildcard,
values: [[value, []]],
values: [[value, null, []]],
};

@@ -361,4 +361,4 @@ }

each(values, function (_a) {
var v = _a[0], p = _a[1];
return iteratee(v, p[p.length - 1], p.join('.'), data);
var v = _a[0], c = _a[1], p = _a[2];
return iteratee(v, p[p.length - 1], c, p.join('.'), data);
});

@@ -375,4 +375,4 @@ };

return values.map(function (_a) {
var v = _a[0], p = _a[1];
return iteratee(v, p[p.length - 1], p.join('.'), data);
var v = _a[0], c = _a[1], p = _a[2];
return iteratee(v, p[p.length - 1], c, p.join('.'), data);
});

@@ -379,0 +379,0 @@ };

{
"name": "dot-wild",
"version": "1.1.1",
"version": "2.0.0",
"description": "Use powerful dot notation (dot path + wildcard) to manipulate properties of JSON",

@@ -13,3 +13,3 @@ "main": "lib/index.js",

"test:unit": "mocha --compilers ts:ts-node/register,tsx:ts-node/register 'test/**/*.spec.ts'",
"docs": "typedoc --excludeNotExported --excludePrivate --out docs/ src/",
"docs": "typedoc --excludeNotExported --excludePrivate --out docs/ src/ && touch docs/.nojekyll",
"prepublish": "npm run build"

@@ -16,0 +16,0 @@ },

@@ -162,10 +162,11 @@ dot-wild

*/
dot.forEach(postData, 'data.posts.*.id', (value, key, path, data) => {
// value => 1, 2
// key => 'id', 'id
// path => 'data.posts.0.id', 'data.posts.1.id'
// data => postData...
dot.forEach(postData, 'data.posts.*.id', (value, key, context, path, data) => {
// value => 1, 2
// key => 'id', 'id'
// context => { id: 1, title: 'post 1' }, { id: 2, title: 'post 2' }
// path => 'data.posts.0.id', 'data.posts.1.id'
// data => postData...
});
dot.map(postData, 'data.tags.*.name', (value, key, path, data) => {
dot.map(postData, 'data.tags.*.name', (value, key, context, path, data) => {
return `${dot.get(data, path)} === ${value} (${key})`;

@@ -172,0 +173,0 @@ });

@@ -383,3 +383,4 @@ import * as assert from 'power-assert';

// Normal path
dot.forEach(sampleData, 'nested', (value: any, key: any, path: string, data: any) => {
dot.forEach(sampleData, 'nested', (value: any, key: any, context: any, path: string, data: any) => {
assert(context[key] === value);
assert(dot.get(data, path) === value);

@@ -397,3 +398,4 @@ results.push([value, key, path]);

dot.forEach(sampleData, 'tags.*.*', (value: any, key: any, path: string, data: any) => {
dot.forEach(sampleData, 'tags.*.*', (value: any, key: any, context: any, path: string, data: any) => {
assert(context[key] === value);
assert.deepStrictEqual(dot.get(data, path), value);

@@ -432,3 +434,4 @@ results.push([value, key, path]);

// Normal path
results = dot.map(sampleData, 'tags', (value: any, key: any, path: string, data: any) => {
results = dot.map(sampleData, 'tags', (value: any, key: any, context: any, path: string, data: any) => {
assert(context[key] === value);
assert.deepStrictEqual(dot.get(data, path), value);

@@ -444,3 +447,4 @@ return [value, key, path];

// Use wildcard
results = dot.map(sampleData, 'nested.deep.*.members.*.profile.age', (value: any, key: any, path: string, data: any) => {
results = dot.map(sampleData, 'nested.deep.*.members.*.profile.age', (value: any, key: any, context: any, path: string, data: any) => {
assert(context[key] === value);
assert.deepStrictEqual(dot.get(data, path), value);

@@ -447,0 +451,0 @@ return [value, key, path];

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc