Skip to content

Commit

Permalink
Rebuild dist/*.js sources for v2.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
chbrown committed Nov 13, 2017
1 parent ba5fb1a commit 47c35bf
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 30 deletions.
33 changes: 22 additions & 11 deletions dist/rfc6902.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,19 @@ class Pointer {
// not sure if this the best way to handle non-existant paths...
object = (parent || {})[token];
}
return {
parent: parent,
key: token,
value: object,
};
return { parent, key: token, value: object };
}
get(object) {
return this.evaluate(object).value;
}
set(object, value) {
for (var i = 1, l = this.tokens.length - 1, token = this.tokens[i]; i < l; i++) {
// not sure if this the best way to handle non-existant paths...
object = (object || {})[token];
}
if (object) {
object[this.tokens[this.tokens.length - 1]] = value;
}
}
push(token) {
// mutable
Expand Down Expand Up @@ -131,8 +139,9 @@ function zip(a, b) {
compareArrays(left, right) assumes that `left` and `right` are both Arrays.
*/
function compareArrays(left, right) {
if (left.length !== right.length)
if (left.length !== right.length) {
return false;
}
return zip(left, right).every(pair => compare(pair[0], pair[1]));
}
/**
Expand All @@ -141,8 +150,9 @@ compareObjects(left, right) assumes that `left` and `right` are both Objects.
function compareObjects(left, right) {
var left_keys = Object.keys(left);
var right_keys = Object.keys(right);
if (!compareArrays(left_keys, right_keys))
if (!compareArrays(left_keys, right_keys)) {
return false;
}
return left_keys.every(key => compare(left[key], right[key]));
}
/**
Expand All @@ -169,8 +179,9 @@ function compareObjects(left, right) {
*/
function compare(left, right) {
// strict equality handles literals, numbers, and strings (a sufficient but not necessary cause)
if (left === right)
if (left === right) {
return true;
}
// check arrays
if (Array.isArray(left) && Array.isArray(right)) {
return compareArrays(left, right);
Expand Down Expand Up @@ -480,7 +491,7 @@ function diffArrays(input, output, ptr) {
// the only other case, i === 0 && j === 0, has already been memoized
// the meat of the algorithm:
// sort by cost to find the lowest one (might be several ties for lowest)
// [4, 6, 7, 1, 2].sort((a, b) => a - b); -> [ 1, 2, 4, 6, 7 ]
// [4, 6, 7, 1, 2].sort((a, b) => a - b) -> [ 1, 2, 4, 6, 7 ]
const best = alternatives.sort((a, b) => a.cost - b.cost)[0];
memoized = best;
}
Expand All @@ -502,15 +513,15 @@ function diffArrays(input, output, ptr) {
path: ptr.add(index_token).toString(),
value: array_operation.value,
};
// padding++; // maybe only if array_operation.index > -1 ?
// padding++ // maybe only if array_operation.index > -1 ?
return [operations.concat(operation), padding + 1];
}
else if (isArrayRemove(array_operation)) {
const operation = {
op: array_operation.op,
path: ptr.add(String(array_operation.index + padding)).toString(),
};
// padding--;
// padding--
return [operations.concat(operation), padding - 1];
}
else {
Expand Down

0 comments on commit 47c35bf

Please sign in to comment.