Comparing version 2.1.0-beta.1 to 2.1.0-beta.2
@@ -539,2 +539,8 @@ function _typeof(obj) { | ||
}; | ||
var isObject = function isObject(x) { | ||
return _typeof(x) === 'object' && !Array.isArray(x) && x !== null; | ||
}; | ||
var isValue = function isValue(x) { | ||
return x !== null && x !== undefined; | ||
}; | ||
@@ -742,2 +748,15 @@ var into = function into(f) { | ||
var valueOr = function valueOr(def) { | ||
return compile({ | ||
get: function get(val) { | ||
return isValue(val) ? val : def; | ||
}, | ||
mod: function mod(fn) { | ||
return function (val) { | ||
return isValue(val) ? fn(val) : fn(def); | ||
}; | ||
} | ||
}); | ||
}; | ||
var fill = function fill(filling) { | ||
@@ -760,9 +779,3 @@ return function (obj) { | ||
}; | ||
var isObject = function isObject(x) { | ||
return _typeof(x) === 'object' && !Array.isArray(x) && x !== null; | ||
}; | ||
var isValue = function isValue(x) { | ||
return x !== null && x !== undefined; | ||
}; | ||
export { compile as lens, matching, all$1 as all, unless, updateAll, maybe, mod, set$1 as set, get, identity, flip, always, not, and, or, curry, into, filter, map, find, some, reduce, every, cons, unshift, first, rest, push, concat, append, prepend, has, greaterThan, lessThan, greaterThanEq, lessThanEq, toggle, returns, add, sub, inc, dec, includes, includesi, foldOf, maxOf, minOf, findOf, sumOf, productOf, foldBy, findBy, maxBy, minBy, fill }; | ||
export { compile as lens, matching, all$1 as all, unless, updateAll, maybe, mod, set$1 as set, get, identity, flip, always, not, and, or, curry, into, filter, map, find, some, reduce, every, cons, unshift, first, rest, push, concat, append, prepend, has, greaterThan, lessThan, greaterThanEq, lessThanEq, toggle, returns, isObject, isValue, add, sub, inc, dec, includes, includesi, foldOf, maxOf, minOf, findOf, sumOf, productOf, foldBy, findBy, maxBy, minBy, valueOr, fill }; |
@@ -543,2 +543,8 @@ 'use strict'; | ||
}; | ||
var isObject = function isObject(x) { | ||
return _typeof(x) === 'object' && !Array.isArray(x) && x !== null; | ||
}; | ||
var isValue = function isValue(x) { | ||
return x !== null && x !== undefined; | ||
}; | ||
@@ -746,2 +752,15 @@ var into = function into(f) { | ||
var valueOr = function valueOr(def) { | ||
return compile({ | ||
get: function get(val) { | ||
return isValue(val) ? val : def; | ||
}, | ||
mod: function mod(fn) { | ||
return function (val) { | ||
return isValue(val) ? fn(val) : fn(def); | ||
}; | ||
} | ||
}); | ||
}; | ||
var fill = function fill(filling) { | ||
@@ -764,8 +783,2 @@ return function (obj) { | ||
}; | ||
var isObject = function isObject(x) { | ||
return _typeof(x) === 'object' && !Array.isArray(x) && x !== null; | ||
}; | ||
var isValue = function isValue(x) { | ||
return x !== null && x !== undefined; | ||
}; | ||
@@ -810,2 +823,4 @@ exports.lens = compile; | ||
exports.returns = returns; | ||
exports.isObject = isObject; | ||
exports.isValue = isValue; | ||
exports.add = add; | ||
@@ -827,2 +842,3 @@ exports.sub = sub; | ||
exports.minBy = minBy; | ||
exports.valueOr = valueOr; | ||
exports.fill = fill; |
{ | ||
"name": "shades", | ||
"version": "2.1.0-beta.1", | ||
"version": "2.1.0-beta.2", | ||
"description": "Lens-like functionality with a lodash-style interface.", | ||
@@ -5,0 +5,0 @@ "main": "lib/bundle.js", |
@@ -45,3 +45,4 @@ import { | ||
toggle, | ||
unshift | ||
unshift, | ||
valueOr | ||
} from "shades"; | ||
@@ -235,2 +236,7 @@ | ||
get("bestFriend")(user); // $ExpectType User | undefined | ||
get("bestFriend", valueOr(user))(user); // $ExpectType User | ||
get(all(), "bestFriend")(users); // $ExpectType (User | undefined)[] | ||
get(all(), "bestFriend", valueOr(user))(users); // $ExpectType User[] | ||
filter((user: User) => user.friends.length > 0)(users); // $ExpectType User[] | ||
@@ -237,0 +243,0 @@ filter((user: User) => user.name)(byName); // $ExpectType { [name: string]: User; } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
4605560
2992
2735