New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

shades

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shades - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0-beta.0

8

lib/bundle.es.js

@@ -706,2 +706,8 @@ function _typeof(obj) {

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, 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 };
var fill = function fill(filling) {
return function (obj) {
return _objectSpread({}, obj, filling);
};
};
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, 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 };

@@ -710,2 +710,8 @@ 'use strict';

var fill = function fill(filling) {
return function (obj) {
return _objectSpread({}, obj, filling);
};
};
exports.lens = compile;

@@ -764,1 +770,2 @@ exports.matching = matching;

exports.minBy = minBy;
exports.fill = fill;

8

package.json
{
"name": "shades",
"version": "2.0.0",
"version": "2.1.0-beta.0",
"description": "Lens-like functionality with a lodash-style interface.",

@@ -84,6 +84,6 @@ "main": "lib/bundle.js",

"lodash": "^4.17.11",
"mocha": "5.0.4",
"npm-run-all": "^4.1.3",
"mocha": "^5.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.14.3",
"pulp": "^12.3.0",
"pulp": "^12.3.1",
"purescript": "^0.12.0",

@@ -90,0 +90,0 @@ "rollup": "^0.56.5",

@@ -12,2 +12,3 @@ import {

find,
fill,
findBy,

@@ -81,99 +82,9 @@ findOf,

mod("freinds", toString)(s => s.toUpperCase())(user); // $ExpectError
filter((user: User) => user.friends.length > 0)(users); // $ExpectType User[]
filter((user: User) => user.name)(byName); // $ExpectType { [name: string]: User; }
filter("name")(users); // $ExpectType User[]
filter("name")(byName); // $ExpectType { [name: string]: User; }
filter("butts")(users); // $ExpectError
filter({ name: "john" })(users); // $ExpectType User[]
filter({ name: "john" })(byName); // $ExpectType { [name: string]: User; }
filter({
settings: (settings: string) => settings
})(users); // $ExpectError
filter({
settings: (settings: Settings) => settings
})(users); // $ExpectType User[]
map("name")(users); // $ExpectType string[]
map("name")(byName); // $ExpectType { [key: string]: string; }
map("not-a-key")(users); // $ExpectError
map("not-a-key")(byName); // $ExpectError
map("bestFriend")(users); // $ExpectType (User | undefined)[]
const usersFriends = map("friends")(users); // $ExpectType User[][]
map(1)(usersFriends); // $ExpectType User[]
map(1)(users); // $ExpectError
const usersFriendsByName = map("friends")(byName); // $ExpectType { [key: string]: User[]; }
map(2)(usersFriendsByName); // $ExpectType { [key: string]: User; }
map((x: User) => x.name)(users); // $ExpectType string[]
map({ name: "john", settings: (settings: Settings) => !!settings })(users); // $ExpectType boolean[]
map({ name: "john", settings: (settings: Settings) => !!settings })(byName); // $ExpectType { [key: string]: boolean; }
into("a")({ a: 10 }); // $ExpectType number
into("b")({ a: 10 }); // $ExpectError
into({ a: 10 })({ a: 10 }); // $ExpectType boolean
into({ a: 10 })({ b: 10 }); // $ExpectError
into((x: number) => x + 1)(10); // $ExpectType number
declare const fetchUsers: Promise<User[]>;
// Nested maps require type annotations, but still provide safety
map<User[], string[]>(map("name"))(fetchUsers); // $ExpectType Promise<string[]>
// map<User[], boolean[]>(map('name'))(fetchUsers) // $ExpectError
declare const userMap: Map<string, User>;
declare const userSet: Set<User>;
map("name")(userMap); // $ExpectType Map<string, string>
map("name")(userSet); // $ExpectType Set<string>
find("name")(users); // $ExpectType User | undefined
find("fart")(users); // $ExpectError
find((user: User) => user.friends)(users); // $ExpectType User | undefined
find((user: User) => user.friends.length > 0)(users); // $ExpectType User | undefined
find({ name: "barg" })(users); // $ExpectType User | undefined
find({ name: false })(users); // $ExpectError
find({ name: (s: string) => !!"barg" })(users); // $ExpectType User | undefined
find({ name: (s: Settings) => !!"barg" })(users); // $ExpectError
const a = find({
friends: find({ name: "silent bob" })
})(users);
a; // $ExpectType User | undefined
find({ settings: { permissions: false } })(users); // $ExpectError
find({
settings: { permissions: false }
})(users); // $ExpectError
find({
settings: { permissions: (perm: string) => !!perm }
})(users); // ExpectType User | undefined
find({
settings: { permissions: (perm: boolean) => !!perm }
})(users); // $ExpectError
some("name")(users); // $ExpectType boolean
some((user: User) => user.friends)(users); // $ExpectType boolean
some((user: User) => user.friends.length > 0)(users); // $ExpectType boolean
some({ name: "barg" })(users); // $ExpectType boolean
some({ name: false })(users); // $ExpectError
some({ name: (s: string) => !!"barg" })(users); // $ExpectType boolean
some({ name: (s: boolean) => !!"barg" })(users); // $ExpectError
cons(1)([1, 2, 3]); // $ExpectType number[]
cons("a")(["a", "b", "c"]); // $ExpectType string[]
cons(1)(2); // $ExpectError
cons(1)(["a", "b", "c"]); // $ExpectError
cons("1")([1, 2, 3]); // $ExpectError
first([1, 3, 4]); // $ExpectType number
first(users); // $ExpectType User
first("hi"); // $ExpectType string
first(true); // $ExpectError
rest([1, 3, 4]); // $ExpectType number[]
rest(users); // $ExpectType User[]
rest("hi"); // $ExpectError
rest(true); // $ExpectError
concat([1, 2, 3])([2, 3]); // $ExpectType number[]
// [2, 3, 1, 2, 3]
concat(["hi"])(["wo"]); // $ExpectType string[]
// ['wo', 'hi']
concat(["hi"])([1, 2, 3]); // $ExpectError
prepend([1, 2, 3])([2, 3]); // $ExpectType number[]
// [1, 2, 3, 2, 3]
prepend(["hi"])(["wo"]); // $ExpectType string[]
// ['hi', 'wo']
prepend(["hi"])([1, 2, 3]); // $ExpectError
users[0].posts.reduce(maxOf("likes")); // $ExpectType Post

@@ -207,9 +118,3 @@ users[0].posts.reduce(maxOf("title")); // $ExpectError

// Cards on the table this one does not type check with polymorphic
// functions very well. Rank-N type inference is hard to you might
// have to help it along
declare function numAndBool(a: number): (b: boolean) => boolean;
flip(numAndBool); // $ExpectType (b: boolean) => (a: number) => boolean
flip<"hi", 7, "hi">(always)(7)("hi"); // $ExpectType "hi"
flip<"hi", 7, 7>(always)(7)("hi"); // $ExpectError
flip(always); // $ExpectType <A>(b: any) => (a: A) => A

@@ -247,7 +152,11 @@ always(10)(map); // $ExpectType number

into("a")({ a: 10 }); // $ExpectType number
into("b")({ a: 10 }); // $ExpectError
into({ a: 10 })({ a: 10 }); // $ExpectType boolean
into({ a: 10 })({ b: 10 }); // $ExpectError
into((x: number) => x + 1)(10); // $ExpectType number
fill({ a: 10 })({ a: undefined, b: 5 }).a; // $ExpectType number
fill({ a: 10 })({}).a; // $ExpectType number
// 'bestFriend' is an optional `User` property on the `User` object
get("bestFriend", "name")(user); // $ExpectType ErrorCannotLensIntoOptionalKey<User | undefined, "name">
const friendsWithMyself = fill({ bestFriend: user })(user);
get("bestFriend", "name")(friendsWithMyself); // $ExpectType string
get("bestFriend", "bestFriend", "name")(user); // $ExpectType ErrorCannotLensIntoOptionalKey<ErrorCannotLensIntoOptionalKey<User | undefined, "bestFriend">, "name">
const deepFriendsWithMyself = fill({ bestFriend: friendsWithMyself })(user);
get("bestFriend", "bestFriend", "name")(deepFriendsWithMyself); // $ExpectType string

@@ -296,2 +205,8 @@ has({ a: 1 }); // $ExpectType (obj: HasPattern<{ a: number; }>) => boolean

get("name")(user); // $ExpectType string
get(0, "name")(users); // $ExpectType string
get(0, "fart")(users); // $ExpectError
get("bestFriend")(user); // $ExpectType User | undefined
get("bestFriend", "name")(user); // $ExpectType ErrorCannotLensIntoOptionalKey<User | undefined, "name">
includes("hello")("hello"); // $ExpectType boolean

@@ -322,1 +237,98 @@ includes("hello")(false); // $ExpectError

get("friends", minBy((user: User) => user.settings), "pots")(user); // $ExpectError
filter((user: User) => user.friends.length > 0)(users); // $ExpectType User[]
filter((user: User) => user.name)(byName); // $ExpectType { [name: string]: User; }
filter("name")(users); // $ExpectType User[]
filter("name")(byName); // $ExpectType { [name: string]: User; }
filter("butts")(users); // $ExpectError
filter({ name: "john" })(users); // $ExpectType User[]
filter({ name: "john" })(byName); // $ExpectType { [name: string]: User; }
filter({
settings: (settings: string) => settings
})(users); // $ExpectError
filter({
settings: (settings: Settings) => settings
})(users); // $ExpectType User[]
map("name")(users); // $ExpectType string[]
map("name")(byName); // $ExpectType { [key: string]: string; }
map("not-a-key")(users); // $ExpectError
map("not-a-key")(byName); // $ExpectError
map("bestFriend")(users); // $ExpectType (User | undefined)[]
const usersFriends = map("friends")(users); // $ExpectType User[][]
map(1)(usersFriends); // $ExpectType User[]
map(1)(users); // $ExpectError
const usersFriendsByName = map("friends")(byName); // $ExpectType { [key: string]: User[]; }
map(2)(usersFriendsByName); // $ExpectType { [key: string]: User; }
map((x: User) => x.name)(users); // $ExpectType string[]
map({ name: "john", settings: (settings: Settings) => !!settings })(users); // $ExpectType boolean[]
map({ name: "john", settings: (settings: Settings) => !!settings })(byName); // $ExpectType { [key: string]: boolean; }
declare const fetchUsers: Promise<User[]>;
// Nested maps require type annotations, but still provide safety
map<User[], string[]>(map("name"))(fetchUsers); // $ExpectType Promise<string[]>
// map<User[], boolean[]>(map('name'))(fetchUsers) // $ExpectError
declare const userMap: Map<string, User>;
declare const userSet: Set<User>;
map("name")(userMap); // $ExpectType Map<string, string>
map("name")(userSet); // $ExpectType Set<string>
find("name")(users); // $ExpectType User | undefined
find("fart")(users); // $ExpectError
find((user: User) => user.friends)(users); // $ExpectType User | undefined
find((user: User) => user.friends.length > 0)(users); // $ExpectType User | undefined
find({ name: "barg" })(users); // $ExpectType User | undefined
find({ name: false })(users); // $ExpectError
find({ name: (s: string) => !!"barg" })(users); // $ExpectType User | undefined
find({ name: (s: Settings) => !!"barg" })(users); // $ExpectError
const a = find({
friends: find({ name: "silent bob" })
})(users);
a; // $ExpectType User | undefined
find({ settings: { permissions: false } })(users); // $ExpectError
find({
settings: { permissions: false }
})(users); // $ExpectError
find({
settings: { permissions: (perm: string) => !!perm }
})(users); // ExpectType User | undefined
find({
settings: { permissions: (perm: boolean) => !!perm }
})(users); // $ExpectError
some("name")(users); // $ExpectType boolean
some((user: User) => user.friends)(users); // $ExpectType boolean
some((user: User) => user.friends.length > 0)(users); // $ExpectType boolean
some({ name: "barg" })(users); // $ExpectType boolean
some({ name: false })(users); // $ExpectError
some({ name: (s: string) => !!"barg" })(users); // $ExpectType boolean
some({ name: (s: boolean) => !!"barg" })(users); // $ExpectError
cons(1)([1, 2, 3]); // $ExpectType number[]
cons("a")(["a", "b", "c"]); // $ExpectType string[]
cons(1)(2); // $ExpectError
cons(1)(["a", "b", "c"]); // $ExpectError
cons("1")([1, 2, 3]); // $ExpectError
first([1, 3, 4]); // $ExpectType number
first(users); // $ExpectType User
first("hi"); // $ExpectType string
first(true); // $ExpectError
rest([1, 3, 4]); // $ExpectType number[]
rest(users); // $ExpectType User[]
rest("hi"); // $ExpectError
rest(true); // $ExpectError
concat([1, 2, 3])([2, 3]); // $ExpectType number[]
// [2, 3, 1, 2, 3]
concat(["hi"])(["wo"]); // $ExpectType string[]
// ['wo', 'hi']
concat(["hi"])([1, 2, 3]); // $ExpectError
prepend([1, 2, 3])([2, 3]); // $ExpectType number[]
// [1, 2, 3, 2, 3]
prepend(["hi"])(["wo"]); // $ExpectType string[]
// ['hi', 'wo']
prepend(["hi"])([1, 2, 3]); // $ExpectError

@@ -26,9 +26,15 @@ // TypeScript Version: 3.1

| { [_ in K]: V }
| { [_ in K]?: V };
| { [_ in K]?: V | undefined };
interface ErrorCannotLensIntoOptionalKey<T, K> {
error: 'You have tried to lens through an optional key. Consider using `fill` to provide defaults to your object';
}
// prettier-ignore
export type KeyAt<T, K extends string> =
T extends { [_ in K]: any } ? T[K] :
T extends { [_ in K]?: any } ? (T[K] | undefined) :
never;
[T] extends [undefined] ? undefined:
[T] extends [null] ? null :
[T] extends [{ [_ in K]: any }] ? T[K] :
[T] extends [{ [_ in K]?: any }] ? T[K] :
ErrorCannotLensIntoOptionalKey<T, K>;

@@ -57,2 +63,11 @@ export type Collection<V, K = any> =

export type FillingPattern<Pattern> = {
[K in keyof Pattern]?: Pattern[K] | FillingPattern<Pattern[K]>
};
export type Fill<T extends FillingPattern<P>, P> = {
[K in Exclude<keyof T, keyof P>]: T[K]
} &
{ [K in keyof P]: P[K] };
export type Fn0<Out> = () => Out;

@@ -59,0 +74,0 @@ export type Fn1<A, Out> = (a: A) => Out;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc