@sanity/mutator
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -96,18 +96,8 @@ 'use strict'; | ||
var length = probe.length(); | ||
if (head.constraintTargetIsSelf()) { | ||
for (var i = 0; i < length; i++) { | ||
// Push new descenders with constraint translated to literal indices | ||
// where they match | ||
if (head.testConstraint(probe.getIndex(i))) { | ||
result.push(new Descender(new _Expression2.default({ type: 'index', value: i }), this.tail)); | ||
} | ||
for (var i = 0; i < length; i++) { | ||
// Push new descenders with constraint translated to literal indices | ||
// where they match | ||
if (head.testConstraint(probe.getIndex(i))) { | ||
result.push(new Descender(new _Expression2.default({ type: 'index', value: i }), this.tail)); | ||
} | ||
} else { | ||
// The target of the constraint is really the values of the descendants | ||
// Push the constraint back onto the tail | ||
var newTail = head.concat(this.tail); | ||
// Then make descenders for all indices | ||
for (var _i = 0; _i < length; _i++) { | ||
result.push(new Descender(new _Expression2.default({ type: 'index', value: _i }), newTail)); | ||
} | ||
} | ||
@@ -114,0 +104,0 @@ return result; |
{ | ||
"name": "@sanity/mutator", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "A set of models to make it easier to utilize the powerful real time collaborative features of Sanity", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -72,22 +72,9 @@ // @flow | ||
const length = probe.length() | ||
if (head.constraintTargetIsSelf()) { | ||
for (let i = 0; i < length; i++) { | ||
// Push new descenders with constraint translated to literal indices | ||
// where they match | ||
if (head.testConstraint(probe.getIndex(i))) { | ||
result.push(new Descender( | ||
new Expression({type: 'index', value: i}), | ||
this.tail | ||
)) | ||
} | ||
} | ||
} else { | ||
// The target of the constraint is really the values of the descendants | ||
// Push the constraint back onto the tail | ||
const newTail = head.concat(this.tail) | ||
// Then make descenders for all indices | ||
for (let i = 0; i < length; i++) { | ||
result.push(new Descender( | ||
for (let i = 0; i < length; i++) { | ||
// Push new descenders with constraint translated to literal indices | ||
// where they match | ||
if (head.testConstraint(probe.getIndex(i))) { | ||
result.push(new Descender( | ||
new Expression({type: 'index', value: i}), | ||
newTail | ||
this.tail | ||
)) | ||
@@ -94,0 +81,0 @@ } |
@@ -28,4 +28,3 @@ import { test } from 'tap' | ||
expectDescendants(tap, iterated, [ | ||
'<[0]|[a == 7][b,c].d>', | ||
'<[1]|[a == 7][b,c].d>', | ||
'<[1]|[b,c].d>' | ||
]) | ||
@@ -32,0 +31,0 @@ tap.end() |
@@ -122,3 +122,15 @@ /* eslint-disable id-length, quote-props */ | ||
{ | ||
name: 'By key', | ||
before: { | ||
a: [{key: 'one'}, {key: 'two'}], | ||
}, | ||
patch: { | ||
unset: ['a[key=="one"]'] | ||
}, | ||
after: { | ||
a: [{key: 'two'}], | ||
} | ||
} | ||
] |
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
317823
97
6665