Comparing version 0.1.0 to 1.0.0
@@ -129,16 +129,16 @@ /* | ||
var peg$FAILED = {}, | ||
peg$startRuleFunctions = { Attribute: peg$parseAttribute }, | ||
peg$startRuleFunction = peg$parseAttribute, | ||
peg$c0 = function peg$c0(attr, next) { | ||
peg$startRuleFunctions = { start: peg$parsestart }, | ||
peg$startRuleFunction = peg$parsestart, | ||
peg$c0 = ".", | ||
peg$c1 = peg$literalExpectation(".", false), | ||
peg$c2 = function peg$c2(attr, next) { | ||
return buildParseList('attr', attr, next); | ||
}, | ||
peg$c1 = "]", | ||
peg$c2 = peg$literalExpectation("]", false), | ||
peg$c3 = function peg$c3(idx, next) { | ||
peg$c3 = "[", | ||
peg$c4 = peg$literalExpectation("[", false), | ||
peg$c5 = "]", | ||
peg$c6 = peg$literalExpectation("]", false), | ||
peg$c7 = function peg$c7(idx, next) { | ||
return buildParseList('idx', idx, next); | ||
}, | ||
peg$c4 = ".", | ||
peg$c5 = peg$literalExpectation(".", false), | ||
peg$c6 = "[", | ||
peg$c7 = peg$literalExpectation("[", false), | ||
peg$c8 = /^[a-zA-Z]/, | ||
@@ -154,3 +154,3 @@ peg$c9 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false), | ||
peg$c15 = function peg$c15() { | ||
return text(); | ||
return parseInt(text()); | ||
}, | ||
@@ -286,20 +286,8 @@ peg$currPos = 0, | ||
function peg$parseAttribute() { | ||
var s0, s1, s2; | ||
function peg$parsestart() { | ||
var s0; | ||
s0 = peg$currPos; | ||
s1 = peg$parseId(); | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseSeq(); | ||
if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c0(s1, s2); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
s0 = peg$parseAttribute(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parseIndex(); | ||
} | ||
@@ -310,22 +298,22 @@ | ||
function peg$parseIndex() { | ||
function peg$parseAttribute() { | ||
var s0, s1, s2, s3; | ||
s0 = peg$currPos; | ||
s1 = peg$parseNum(); | ||
if (input.charCodeAt(peg$currPos) === 46) { | ||
s1 = peg$c0; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
peg$fail(peg$c1); | ||
} | ||
} | ||
if (s1 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 93) { | ||
s2 = peg$c1; | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
peg$fail(peg$c2); | ||
} | ||
} | ||
s2 = peg$parseId(); | ||
if (s2 !== peg$FAILED) { | ||
s3 = peg$parseSeq(); | ||
s3 = peg$parseTail(); | ||
if (s3 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c3(s1, s3); | ||
s1 = peg$c2(s2, s3); | ||
s0 = s1; | ||
@@ -348,8 +336,8 @@ } else { | ||
function peg$parseSeq() { | ||
var s0, s1, s2; | ||
function peg$parseIndex() { | ||
var s0, s1, s2, s3, s4; | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 46) { | ||
s1 = peg$c4; | ||
if (input.charCodeAt(peg$currPos) === 91) { | ||
s1 = peg$c3; | ||
peg$currPos++; | ||
@@ -359,34 +347,27 @@ } else { | ||
if (peg$silentFails === 0) { | ||
peg$fail(peg$c5); | ||
peg$fail(peg$c4); | ||
} | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseAttribute(); | ||
s2 = peg$parseNum(); | ||
if (s2 !== peg$FAILED) { | ||
s1 = [s1, s2]; | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$currPos; | ||
if (input.charCodeAt(peg$currPos) === 91) { | ||
s1 = peg$c6; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
peg$fail(peg$c7); | ||
if (input.charCodeAt(peg$currPos) === 93) { | ||
s3 = peg$c5; | ||
peg$currPos++; | ||
} else { | ||
s3 = peg$FAILED; | ||
if (peg$silentFails === 0) { | ||
peg$fail(peg$c6); | ||
} | ||
} | ||
} | ||
if (s1 !== peg$FAILED) { | ||
s2 = peg$parseIndex(); | ||
if (s2 !== peg$FAILED) { | ||
s1 = [s1, s2]; | ||
s0 = s1; | ||
if (s3 !== peg$FAILED) { | ||
s4 = peg$parseTail(); | ||
if (s4 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c7(s2, s4); | ||
s0 = s1; | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
} else { | ||
@@ -400,4 +381,18 @@ peg$currPos = s0; | ||
} | ||
} else { | ||
peg$currPos = s0; | ||
s0 = peg$FAILED; | ||
} | ||
return s0; | ||
} | ||
function peg$parseTail() { | ||
var s0; | ||
s0 = peg$parseAttribute(); | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parseIndex(); | ||
} | ||
if (s0 === peg$FAILED) { | ||
s0 = null; | ||
@@ -503,3 +498,3 @@ } | ||
if (next) { | ||
return [parsed].concat(next[1]); | ||
return [parsed].concat(next); | ||
} else { | ||
@@ -506,0 +501,0 @@ return parsed; |
@@ -32,9 +32,9 @@ 'use strict'; | ||
function aux(object, lenses) { | ||
var _lenses = _toArray(lenses); | ||
var _lenses = _toArray(lenses), | ||
first = _lenses[0], | ||
rest = _lenses.slice(1); | ||
var first = _lenses[0]; | ||
var rest = _lenses.slice(1); | ||
if (rest.length === 0) return first.mod(f)(object); | ||
if (rest.length === 0) { | ||
return first.mod(f)(object); | ||
} | ||
return first.mod((0, _utils.always)(aux(first.get(object), rest)))(object); | ||
@@ -41,0 +41,0 @@ } |
{ | ||
"name": "shades", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "Lens-like functionality with a lodash-style interface.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -11,14 +11,14 @@ ## shades | ||
const store = { | ||
users: [ | ||
{ | ||
name: 'Jack Sparrow', | ||
posts: [ | ||
{ | ||
title: 'Why is the rum always gone? A dissertation on Carribean trade deficit' | ||
} | ||
], | ||
... | ||
}, | ||
... | ||
] | ||
users: [ | ||
{ | ||
name: 'Jack Sparrow', | ||
posts: [ | ||
{ | ||
title: 'Why is the rum always gone? A dissertation on Carribean trade deficit' | ||
} | ||
], | ||
... | ||
}, | ||
... | ||
] | ||
} | ||
@@ -36,14 +36,14 @@ | ||
{...store, | ||
users: store.users.map((user, idx) => ( | ||
idx === userIdx | ||
? {...user, | ||
posts: user.posts.map((post, idx) => | ||
idx === postIdx | ||
? {...post, | ||
title: capitalize(post.title) | ||
} | ||
: post) | ||
} | ||
: user | ||
) | ||
users: store.users.map((user, idx) => ( | ||
idx === userIdx | ||
? {...user, | ||
posts: user.posts.map((post, idx) => | ||
idx === postIdx | ||
? {...post, | ||
title: capitalize(post.title) | ||
} | ||
: post) | ||
} | ||
: user | ||
) | ||
} | ||
@@ -57,6 +57,6 @@ ``` | ||
``` | ||
mod(`users[${userIdx}].posts[${postIdx}]`) | ||
(capitalize) | ||
(store) | ||
mod(`.users[${userIdx}].posts[${postIdx}]`) | ||
(capitalize) | ||
(store) | ||
``` | ||
@@ -75,6 +75,6 @@ | ||
``` | ||
> "a.b[3].d" // focus is the d field | ||
> ".a.b[3].d" // focus is the d field | ||
> const idx = 10 | ||
> `a.b[${idx}]` // focus is the 11th element of b | ||
> `.a.b[${idx}]` // focus is the 11th element of b | ||
``` | ||
@@ -86,3 +86,3 @@ | ||
``` | ||
> get('a.b.c')({a: {b: {c: 7}}}) | ||
> get('.a.b.c')({a: {b: {c: 7}}}) | ||
7 | ||
@@ -95,3 +95,3 @@ ``` | ||
``` | ||
> set('a.b.c')(10)({a: {b: {c: 7}}}) | ||
> set('.a.b.c')(10)({a: {b: {c: 7}}}) | ||
{a: {b: {c: 10}}} | ||
@@ -105,3 +105,3 @@ ``` | ||
> const inc = n => n + 1 | ||
> mod('a.b.c')(inc)({a: {b: {c: 7}}}) | ||
> mod('.a.b.c')(inc)({a: {b: {c: 7}}}) | ||
{a: {b: {c: 8}}} | ||
@@ -108,0 +108,0 @@ ``` |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
65787
16
0
668