Skip to content

Commit

Permalink
13.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed May 17, 2018
1 parent 1eda410 commit edf55f3
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 5 deletions.
38 changes: 38 additions & 0 deletions dist/partial.lenses.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ var toRegExpU = function toRegExpU(str, flags) {
return I.isString(str) ? new RegExp(replace(/[|\\{}()[\]^$+*?.]/g, '\\$&', str), flags) : str;
};

//

var returnAsync = function returnAsync(x) {
return Promise.resolve(x);
};

var chainAsync = function chainAsync(xyP, xP) {
return null != xP && I.isFunction(xP.then) ? xP.then(xyP) : xyP(xP);
};

//

var toStringPartial = function toStringPartial(x) {
return void 0 !== x ? String(x) : '';
};
Expand Down Expand Up @@ -554,6 +566,10 @@ var modifyU = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? I.id : par(0
}
});

var modifyAsyncU = function modifyAsyncU(o, f, s) {
return returnAsync(toFunction(o)(s, void 0, IdentityAsync, f));
};

function makeIx(i) {
var ix = function ix(s, j) {
return ix.v = j, s;
Expand Down Expand Up @@ -1006,6 +1022,19 @@ var Identity = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? I.id : I.fr
chain: I.applyU
});

var IdentityAsync = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? I.id : I.freeze)({
map: chainAsync,
ap: function ap(xyP, xP) {
return chainAsync(function (xP) {
return chainAsync(function (xyP) {
return xyP(xP);
}, xyP);
}, xP);
},
of: I.id,
chain: chainAsync
});

var Constant = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? I.id : I.freeze)({
map: I.sndU
});
Expand All @@ -1031,6 +1060,8 @@ var assign = /*#__PURE__*/I.curry(function (o, x, s) {

var modify = /*#__PURE__*/I.curry(modifyU);

var modifyAsync = /*#__PURE__*/I.curry(modifyAsyncU);

var remove = /*#__PURE__*/I.curry(function (o, s) {
return setU(o, void 0, s);
});
Expand All @@ -1041,6 +1072,10 @@ var transform = /*#__PURE__*/I.curry(function (o, s) {
return modifyU(o, I.id, s);
});

var transformAsync = /*#__PURE__*/I.curry(function (o, s) {
return modifyAsyncU(o, I.id, s);
});

var traverse = /*#__PURE__*/I.curry(traverseU);

// Nesting
Expand Down Expand Up @@ -1867,13 +1902,16 @@ var pointer = function pointer(s) {

exports.seemsArrayLike = seemsArrayLike;
exports.Identity = Identity;
exports.IdentityAsync = IdentityAsync;
exports.Constant = Constant;
exports.toFunction = toFunction;
exports.assign = assign;
exports.modify = modify;
exports.modifyAsync = modifyAsync;
exports.remove = remove;
exports.set = set;
exports.transform = transform;
exports.transformAsync = transformAsync;
exports.traverse = traverse;
exports.compose = compose;
exports.flat = flat;
Expand Down
39 changes: 37 additions & 2 deletions dist/partial.lenses.es.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isString, isArray, freeze, isObject, id, acyclicEqualsU, array0, object0, sndU, always, curry, isFunction, curryN, assocPartialU, dissocPartialU, isNumber, constructorOf, toObject, applyU, isDefined, keys, hasU, arityN, assign } from 'infestines';
import { isString, isFunction, isArray, freeze, isObject, id, acyclicEqualsU, array0, object0, sndU, always, curry, curryN, arityN, assocPartialU, dissocPartialU, isNumber, constructorOf, toObject, applyU, isDefined, keys, hasU, assign } from 'infestines';

var addU = function addU(x, y) {
return x + y;
Expand Down Expand Up @@ -141,6 +141,18 @@ var toRegExpU = function toRegExpU(str, flags) {
return isString(str) ? new RegExp(replace(/[|\\{}()[\]^$+*?.]/g, '\\$&', str), flags) : str;
};

//

var returnAsync = function returnAsync(x) {
return Promise.resolve(x);
};

var chainAsync = function chainAsync(xyP, xP) {
return null != xP && isFunction(xP.then) ? xP.then(xyP) : xyP(xP);
};

//

var toStringPartial = function toStringPartial(x) {
return void 0 !== x ? String(x) : '';
};
Expand Down Expand Up @@ -550,6 +562,10 @@ var modifyU = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : par(0,
}
});

var modifyAsyncU = function modifyAsyncU(o, f, s) {
return returnAsync(toFunction(o)(s, void 0, IdentityAsync, f));
};

function makeIx(i) {
var ix = function ix(s, j) {
return ix.v = j, s;
Expand Down Expand Up @@ -1002,6 +1018,19 @@ var Identity = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : freeze
chain: applyU
});

var IdentityAsync = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : freeze)({
map: chainAsync,
ap: function ap(xyP, xP) {
return chainAsync(function (xP) {
return chainAsync(function (xyP) {
return xyP(xP);
}, xyP);
}, xP);
},
of: id,
chain: chainAsync
});

var Constant = /*#__PURE__*/(process.env.NODE_ENV === 'production' ? id : freeze)({
map: sndU
});
Expand All @@ -1027,6 +1056,8 @@ var assign$1 = /*#__PURE__*/curry(function (o, x, s) {

var modify = /*#__PURE__*/curry(modifyU);

var modifyAsync = /*#__PURE__*/curry(modifyAsyncU);

var remove = /*#__PURE__*/curry(function (o, s) {
return setU(o, void 0, s);
});
Expand All @@ -1037,6 +1068,10 @@ var transform = /*#__PURE__*/curry(function (o, s) {
return modifyU(o, id, s);
});

var transformAsync = /*#__PURE__*/curry(function (o, s) {
return modifyAsyncU(o, id, s);
});

var traverse = /*#__PURE__*/curry(traverseU);

// Nesting
Expand Down Expand Up @@ -1861,4 +1896,4 @@ var pointer = function pointer(s) {
return ts;
};

export { seemsArrayLike, Identity, Constant, toFunction, assign$1 as assign, modify, remove, set, transform, traverse, compose, flat, lazy, choices, choose, cond, condOf, ifElse, iftes, orElse, chain, choice, unless, when, optional, zero, assignOp, modifyOp, setOp, removeOp, log, seq, branchOr, branch, branches, elems, elemsTotal, entries, keys$1 as keys, matches, values, children, flatten, query, satisfying, leafs, all, and$1 as and, any, collectAs, collect, concatAs, concat, countIf, count, countsAs, counts, foldl, foldr, forEach, forEachWith, isDefined$1 as isDefined, isEmpty, joinAs, join, maximumBy, maximum, meanAs, mean, minimumBy, minimum, none, or$1 as or, productAs, product, selectAs, select, sumAs, sum, get, lens, setter, foldTraversalLens, defaults, define, normalize, required, reread, rewrite, append, filter, find, findWith, first, index, last, prefix, slice, suffix, pickIn, prop, props, propsOf, removable, valueOr, pick, replace$1 as replace, getInverse, iso, array, inverse, complement, identity, indexed, is, keyed, reverse, singleton, uri, uriComponent, json, dropPrefix, dropSuffix, replaces, split, uncouple, add$1 as add, divide, multiply$1 as multiply, negate$1 as negate, subtract, pointer };
export { seemsArrayLike, Identity, IdentityAsync, Constant, toFunction, assign$1 as assign, modify, modifyAsync, remove, set, transform, transformAsync, traverse, compose, flat, lazy, choices, choose, cond, condOf, ifElse, iftes, orElse, chain, choice, unless, when, optional, zero, assignOp, modifyOp, setOp, removeOp, log, seq, branchOr, branch, branches, elems, elemsTotal, entries, keys$1 as keys, matches, values, children, flatten, query, satisfying, leafs, all, and$1 as and, any, collectAs, collect, concatAs, concat, countIf, count, countsAs, counts, foldl, foldr, forEach, forEachWith, isDefined$1 as isDefined, isEmpty, joinAs, join, maximumBy, maximum, meanAs, mean, minimumBy, minimum, none, or$1 as or, productAs, product, selectAs, select, sumAs, sum, get, lens, setter, foldTraversalLens, defaults, define, normalize, required, reread, rewrite, append, filter, find, findWith, first, index, last, prefix, slice, suffix, pickIn, prop, props, propsOf, removable, valueOr, pick, replace$1 as replace, getInverse, iso, array, inverse, complement, identity, indexed, is, keyed, reverse, singleton, uri, uriComponent, json, dropPrefix, dropSuffix, replaces, split, uncouple, add$1 as add, divide, multiply$1 as multiply, negate$1 as negate, subtract, pointer };
38 changes: 38 additions & 0 deletions dist/partial.lenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@
return I.isString(str) ? new RegExp(replace(/[|\\{}()[\]^$+*?.]/g, '\\$&', str), flags) : str;
};

//

var returnAsync = function returnAsync(x) {
return Promise.resolve(x);
};

var chainAsync = function chainAsync(xyP, xP) {
return null != xP && I.isFunction(xP.then) ? xP.then(xyP) : xyP(xP);
};

//

var toStringPartial = function toStringPartial(x) {
return void 0 !== x ? String(x) : '';
};
Expand Down Expand Up @@ -554,6 +566,10 @@
}
});

var modifyAsyncU = function modifyAsyncU(o, f, s) {
return returnAsync(toFunction(o)(s, void 0, IdentityAsync, f));
};

function makeIx(i) {
var ix = function ix(s, j) {
return ix.v = j, s;
Expand Down Expand Up @@ -1006,6 +1022,19 @@
chain: I.applyU
});

var IdentityAsync = /*#__PURE__*/(0, I.freeze)({
map: chainAsync,
ap: function ap(xyP, xP) {
return chainAsync(function (xP) {
return chainAsync(function (xyP) {
return xyP(xP);
}, xyP);
}, xP);
},
of: I.id,
chain: chainAsync
});

var Constant = /*#__PURE__*/(0, I.freeze)({
map: I.sndU
});
Expand All @@ -1031,6 +1060,8 @@

var modify = /*#__PURE__*/I.curry(modifyU);

var modifyAsync = /*#__PURE__*/I.curry(modifyAsyncU);

var remove = /*#__PURE__*/I.curry(function (o, s) {
return setU(o, void 0, s);
});
Expand All @@ -1041,6 +1072,10 @@
return modifyU(o, I.id, s);
});

var transformAsync = /*#__PURE__*/I.curry(function (o, s) {
return modifyAsyncU(o, I.id, s);
});

var traverse = /*#__PURE__*/I.curry(traverseU);

// Nesting
Expand Down Expand Up @@ -1867,13 +1902,16 @@

exports.seemsArrayLike = seemsArrayLike;
exports.Identity = Identity;
exports.IdentityAsync = IdentityAsync;
exports.Constant = Constant;
exports.toFunction = toFunction;
exports.assign = assign;
exports.modify = modify;
exports.modifyAsync = modifyAsync;
exports.remove = remove;
exports.set = set;
exports.transform = transform;
exports.transformAsync = transformAsync;
exports.traverse = traverse;
exports.compose = compose;
exports.flat = flat;
Expand Down
2 changes: 1 addition & 1 deletion dist/partial.lenses.min.js

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ <h2><a id="contents"></a> <a href="#contents">≡</a> <a href="https://github.co
<li><a href="#operations-on-optics">Operations on optics</a><ul>
<li><a href="#L-assign" title="L.assign: PLens s {p1: a1, ...ps, ...o} -&gt; {p1: a1, ...ps} -&gt; Maybe s -&gt; Maybe s"><code>L.assign(optic, object, maybeData) ~&gt; maybeData</code></a> <small><sup>v11.13.0</sup></small></li>
<li><a href="#L-modify" title="L.modify: POptic s a -&gt; ((Maybe a, Index) -&gt; Maybe a) -&gt; Maybe s -&gt; Maybe s"><code>L.modify(optic, (maybeValue, index) =&gt; maybeValue, maybeData) ~&gt; maybeData</code></a> <small><sup>v2.2.0</sup></small></li>
<li><a href="#L-modifyAsync" title="L.modifyAsync: POptic s a -&gt; ((Maybe a, Index) -&gt; Promise (Maybe a)) -&gt; Maybe s -&gt; Promise (Maybe s)"><code>L.modifyAsync(optic, (maybeValue, index) =&gt; maybeValuePromise, maybeData) ~&gt; maybeDataPromise</code></a> <small><sup>v13.12.0</sup></small></li>
<li><a href="#L-remove" title="L.remove: POptic s a -&gt; Maybe s -&gt; Maybe s"><code>L.remove(optic, maybeData) ~&gt; maybeData</code></a> <small><sup>v2.0.0</sup></small></li>
<li><a href="#L-set" title="L.set: POptic s a -&gt; Maybe a -&gt; Maybe s -&gt; Maybe s"><code>L.set(optic, maybeValue, maybeData) ~&gt; maybeData</code></a> <small><sup>v1.0.0</sup></small></li>
<li><a href="#L-traverse" title="L.traverse: (Functor|Applicative|Monad) c -&gt; ((Maybe a, Index) -&gt; c b) -&gt; POptic s t a b -&gt; Maybe s -&gt; c t"><code>L.traverse(algebra, (maybeValue, index) =&gt; operation, optic, maybeData) ~&gt; operation</code></a> <small><sup>v10.0.0</sup></small></li>
Expand Down Expand Up @@ -128,6 +129,7 @@ <h2><a id="contents"></a> <a href="#contents">≡</a> <a href="https://github.co
<li><a href="#internals">Internals</a><ul>
<li><a href="#L-Constant" title="L.Constant: Functor"><code>L.Constant ~&gt; Functor</code></a> <small><sup>v13.7.0</sup></small></li>
<li><a href="#L-Identity" title="L.Identity: Monad"><code>L.Identity ~&gt; Monad</code></a> <small><sup>v13.7.0</sup></small></li>
<li><a href="#L-IdentityAsync" title="L.IdentityAsync: Monadish"><code>L.IdentityAsync ~&gt; Monadish</code></a> <small><sup>v13.12.0</sup></small></li>
<li><a href="#L-toFunction" title="L.toFunction: POptic s t a b -&gt; (Maybe s, Index, (Functor|Applicative|Monad) c, (Maybe a, Index) -&gt; c b) -&gt; c t"><code>L.toFunction(optic) ~&gt; optic</code></a> <small><sup>v7.0.0</sup></small></li>
</ul>
</li>
Expand All @@ -136,6 +138,7 @@ <h2><a id="contents"></a> <a href="#contents">≡</a> <a href="https://github.co
<li><a href="#transforms">Transforms</a><ul>
<li><a href="#operations-on-transforms">Operations on transforms</a><ul>
<li><a href="#L-transform" title="L.transform: POptic s a -&gt; Maybe s -&gt; Maybe s"><code>L.transform(optic, maybeData) ~&gt; maybeData</code></a> <small><sup>v11.7.0</sup></small></li>
<li><a href="#L-transformAsync" title="L.transformAsync: POptic s a -&gt; Maybe s -&gt; Promise (Maybe s)"><code>L.transformAsync(optic, maybeData) ~&gt; maybeDataPromise</code></a> <small><sup>v13.12.0</sup></small></li>
</ul>
</li>
<li><a href="#sequencing">Sequencing</a><ul>
Expand Down Expand Up @@ -1031,6 +1034,18 @@ <h5><a id="L-modify"></a> <a href="#contents">≡</a> <a href="https://github.co
R.dec,
{elems: [{x: 1, y: 2}, {x: 3, y: 4}]})

</code></pre>
<h5><a id="L-modifyAsync"></a> <a href="#contents"></a> <a href="https://github.com/calmm-js/partial.lenses/blob/master/README.md#L-modifyAsync"></a> <a href="#L-modifyAsync" title="L.modifyAsync: POptic s a -&gt; ((Maybe a, Index) -&gt; Promise (Maybe a)) -&gt; Maybe s -&gt; Promise (Maybe s)"><code>L.modifyAsync(optic, (maybeValue, index) =&gt; maybeValuePromise, maybeData) ~&gt; maybeDataPromise</code></a> <small><sup>v13.12.0</sup></small></h5>
<p><code>L.modifyAsync</code> allows one to map an asynchronous function over the elements
focused on by the given optic. The result of <code>L.modifyAsync</code> is always a
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">promise</a>.</p>
<p>For example:</p>
<pre><code class="hljs lang-js">L.modifyAsync(
[&#39;elems&#39;, L.elems, &#39;x&#39;],
async x =&gt; x - 1,
{elems: [{x: 1, y: 2}, {x: 3, y: 4}]}
).then(console.log)

</code></pre>
<h5><a id="L-remove"></a> <a href="#contents"></a> <a href="https://github.com/calmm-js/partial.lenses/blob/master/README.md#L-remove"></a> <a href="#L-remove" title="L.remove: POptic s a -&gt; Maybe s -&gt; Maybe s"><code>L.remove(optic, maybeData) ~&gt; maybeData</code></a> <small><sup>v2.0.0</sup></small></h5>
<p><code>L.remove</code> allows one to remove the elements focused on by the given optic.</p>
Expand Down Expand Up @@ -1395,6 +1410,13 @@ <h5><a id="L-Identity"></a> <a href="#contents">≡</a> <a href="https://github.
compatible identity
<a href="https://github.com/rpominov/static-land/blob/master/docs/spec.md#monad"><code>Monad</code></a>
definition used by Partial Lenses.</p>
<h5><a id="L-IdentityAsync"></a> <a href="#contents"></a> <a href="https://github.com/calmm-js/partial.lenses/blob/master/README.md#L-IdentityAsync"></a> <a href="#L-IdentityAsync" title="L.IdentityAsync: Monadish"><code>L.IdentityAsync ~&gt; Monadish</code></a> <small><sup>v13.12.0</sup></small></h5>
<p><code>L.IdentityAsync</code> is like <a href="#L-Identity"><code>L.Identity</code></a>, but allows values to be
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve">thenable</a>.
<a href="https://buzzdecafe.github.io/2018/04/10/no-promises-are-not-monads">JavaScript promises do not form a
monad</a>,
which explains the &quot;monadish&quot;. Fortunately one usually does not want nested
promises in which case the approximation can be close enough.</p>
<h5><a id="L-toFunction"></a> <a href="#contents"></a> <a href="https://github.com/calmm-js/partial.lenses/blob/master/README.md#L-toFunction"></a> <a href="#L-toFunction" title="L.toFunction: POptic s t a b -&gt; (Maybe s, Index, (Functor|Applicative|Monad) c, (Maybe a, Index) -&gt; c b) -&gt; c t"><code>L.toFunction(optic) ~&gt; optic</code></a> <small><sup>v7.0.0</sup></small></h5>
<p><code>L.toFunction</code> converts a given optic, which can be a <a href="#L-prop">string</a>, an
<a href="#L-index">integer</a>, an <a href="#L-compose">array</a>, or a function to a function. This
Expand Down Expand Up @@ -1462,6 +1484,13 @@ <h5><a id="L-transform"></a> <a href="#contents">≡</a> <a href="https://github
<p><code>L.transform(o, s)</code> is shorthand for <a href="#L-modify"><code>L.modify(o, x =&gt; x, s)</code></a> and
is intended for running <a href="#transforms">transforms</a> defined using <a href="#transforming">transform
ops</a>.</p>
<p>For example:</p>
<pre><code class="hljs lang-js">L.transform(
[L.elems, L.modifyOp(x =&gt; -x)],
[1, 2, 3]
)

</code></pre>
<p>Note that</p>
<ul>
<li><a href="#L-assign"><code>L.assign(o, x, s)</code></a> is equivalent to <a href="#L-assignOp"><code>L.transform([o,
Expand All @@ -1473,6 +1502,18 @@ <h5><a id="L-transform"></a> <a href="#contents">≡</a> <a href="https://github
<li><a href="#L-remove"><code>L.remove(o, s)</code></a> is equivalent to <a href="#L-removeOp"><code>L.transform([o, L.removeOp],
s)</code></a>.</li>
</ul>
<h5><a id="L-transformAsync"></a> <a href="#contents"></a> <a href="https://github.com/calmm-js/partial.lenses/blob/master/README.md#L-transformAsync"></a> <a href="#L-transformAsync" title="L.transformAsync: POptic s a -&gt; Maybe s -&gt; Promise (Maybe s)"><code>L.transformAsync(optic, maybeData) ~&gt; maybeDataPromise</code></a> <small><sup>v13.12.0</sup></small></h5>
<p><code>L.transformAsync</code> is like <a href="#L-transform"><code>L.transform</code></a>, but allows
<a href="#L-modifyOp"><code>L.modifyOp</code></a> operations to be asynchronous. The result of
<code>L.transformAsync</code> is always a
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">promise</a>.</p>
<p>For example:</p>
<pre><code class="hljs lang-js">L.transformAsync(
[L.elems, L.modifyOp(async x =&gt; -x)],
[1, 2, 3]
).then(console.log)

</code></pre>
<h4><a id="sequencing"></a> <a href="#contents"></a> <a href="https://github.com/calmm-js/partial.lenses/blob/master/README.md#sequencing"></a> <a href="#sequencing">Sequencing</a></h4>
<p>The <a href="#L-seq"><code>L.seq</code></a> combinator allows one to build <a href="#transforms">transforms</a>
that modify their focus more than once.</p>
Expand Down
Loading

0 comments on commit edf55f3

Please sign in to comment.