Comparing version 1.1.3 to 1.2.0
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.updateAll = exports.always = exports.cons = exports.inc = exports.toggle = exports.matching = exports.compose = exports.lens = exports.view = exports.get = exports.set = exports.over = exports.mod = undefined; | ||
exports.updateAll = exports.has = exports.always = exports.cons = exports.inc = exports.toggle = exports.matching = exports.compose = exports.lens = exports.view = exports.get = exports.set = exports.over = exports.mod = undefined; | ||
@@ -71,2 +71,8 @@ var _setters = require('./lens-consumers/setters.js'); | ||
}); | ||
Object.defineProperty(exports, 'has', { | ||
enumerable: true, | ||
get: function get() { | ||
return _utils.has; | ||
} | ||
}); | ||
@@ -73,0 +79,0 @@ var _lens2 = require('./lens-crafters/lens.js'); |
@@ -7,7 +7,7 @@ 'use strict'; | ||
var _compile = require('../compiler/compile.js'); | ||
var _compile = require('../compiler/compile'); | ||
var _compile2 = _interopRequireDefault(_compile); | ||
var _utils = require('../utils/utils.js'); | ||
var _utils = require('../utils/utils'); | ||
@@ -43,3 +43,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
} | ||
return first.mod((0, _utils.always)(aux(first.get(object), rest))).apply(undefined, [object].concat(params)); | ||
return first.mod(function (obj) { | ||
return aux(obj, rest); | ||
}).apply(undefined, [object].concat(params)); | ||
} | ||
@@ -46,0 +48,0 @@ |
@@ -8,7 +8,7 @@ 'use strict'; | ||
var _compile = require('../compiler/compile.js'); | ||
var _compose = require('./compose'); | ||
var _compile2 = _interopRequireDefault(_compile); | ||
var _compose2 = _interopRequireDefault(_compose); | ||
var _utils = require('../utils/utils.js'); | ||
var _utils = require('../utils/utils'); | ||
@@ -18,5 +18,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// mod :: Lens<a, b> -> (a -> a) -> b -> b | ||
var mod = exports.mod = function mod(lens) { | ||
var mod = exports.mod = function mod() { | ||
for (var _len = arguments.length, lenses = Array(_len), _key = 0; _key < _len; _key++) { | ||
lenses[_key] = arguments[_key]; | ||
} | ||
return function (f) { | ||
return (0, _compile2.default)(lens).mod(f); | ||
return _compose2.default.apply(undefined, lenses).mod(f); | ||
}; | ||
@@ -26,6 +30,10 @@ }; | ||
// set:: Lens<a, b> -> a -> b -> b | ||
var set = exports.set = function set(lens) { | ||
var set = exports.set = function set() { | ||
for (var _len2 = arguments.length, lenses = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
lenses[_key2] = arguments[_key2]; | ||
} | ||
return function (newValue) { | ||
return (0, _compile2.default)(lens).mod((0, _utils.always)(newValue)); | ||
return _compose2.default.apply(undefined, lenses).mod((0, _utils.always)(newValue)); | ||
}; | ||
}; |
@@ -1,27 +0,68 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var toggle = exports.toggle = function toggle(bool) { | ||
return !bool; | ||
return !bool; | ||
}; | ||
var inc = exports.inc = function inc(num) { | ||
return num + 1; | ||
return num + 1; | ||
}; | ||
var always = exports.always = function always(a) { | ||
return function (b) { | ||
return a; | ||
}; | ||
return function (b) { | ||
return a; | ||
}; | ||
}; | ||
var cons = exports.cons = function cons(x) { | ||
return function (xs) { | ||
return [].concat(_toConsumableArray(xs), [x]); | ||
}; | ||
return function (xs) { | ||
return [].concat(_toConsumableArray(xs), [x]); | ||
}; | ||
}; | ||
var every = function every(arr) { | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = arr[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var elem = _step.value; | ||
if (!elem) { | ||
return false; | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
return true; | ||
}; | ||
var has = exports.has = function has(pattern) { | ||
return function (obj) { | ||
return every(Object.keys(pattern).map(function (key) { | ||
return _typeof(pattern[key]) === 'object' && _typeof(obj[key]) === 'object' ? has(pattern[key])(obj[key]) : obj[key] === pattern[key]; | ||
})); | ||
}; | ||
}; |
{ | ||
"name": "shades", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Lens-like functionality with a lodash-style interface.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
70224
747