This repository has been archived by the owner on Jul 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(filter-like): return Partial for objects (#45)
* feat(filter): return partial * feat(omit): return partial * feat(pick): return partial and pick * feat(pickAll): return partial and pick * feat(pickBy): return partial * feat(partition): return partial
- Loading branch information
Showing
26 changed files
with
211 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
import * as R_pickBy from '../ramda/dist/src/pickBy'; | ||
|
||
declare const number_string_object_to_boolean: (x: number, k: string, o: object) => boolean; | ||
declare const string_string_object_to_boolean: (x: string, k: string, o: object) => boolean; | ||
declare const object: object; | ||
declare const string_number_record: Record<string, number>; | ||
declare const a_1_b_2_c_3: { | ||
a: 1, | ||
b: 2, | ||
c: 3, | ||
}; | ||
|
||
// @dts-jest:pass -> object | ||
R_pickBy(string_string_object_to_boolean)(object); | ||
// @dts-jest:pass -> object | ||
R_pickBy(string_string_object_to_boolean, object); | ||
// @dts-jest:fail -> Argument of type 'Record<string, number>' is not assignable to parameter of type 'Dictionary<string>'. | ||
R_pickBy(string_string_object_to_boolean)(string_number_record); | ||
// @dts-jest:fail -> Argument of type 'Record<string, number>' is not assignable to parameter of type 'Dictionary<string>'. | ||
R_pickBy(string_string_object_to_boolean, string_number_record); | ||
|
||
// @dts-jest:pass -> Record<string, string> | ||
R_pickBy(string_string_object_to_boolean)<Record<string, string>>(object); | ||
// @dts-jest:pass -> Record<string, string> | ||
R_pickBy<Record<string, string>>(string_string_object_to_boolean, object); | ||
// @dts-jest:fail -> Argument of type '{ a: 1; b: 2; c: 3; }' is not assignable to parameter of type 'Dictionary<string>'. | ||
R_pickBy(string_string_object_to_boolean)(a_1_b_2_c_3); | ||
// @dts-jest:fail -> Argument of type '{ a: 1; b: 2; c: 3; }' is not assignable to parameter of type 'Dictionary<string>'. | ||
R_pickBy(string_string_object_to_boolean, a_1_b_2_c_3); | ||
|
||
// @dts-jest:pass -> Partial<Dictionary<number>> | ||
R_pickBy(number_string_object_to_boolean)(string_number_record); | ||
// @dts-jest:pass -> Partial<Record<string, number>> | ||
R_pickBy(number_string_object_to_boolean, string_number_record); | ||
|
||
// @dts-jest:pass -> Partial<Dictionary<number>> | ||
R_pickBy(number_string_object_to_boolean)(a_1_b_2_c_3); | ||
// @dts-jest:pass -> Partial<{ a: 1; b: 2; c: 3; }> | ||
R_pickBy(number_string_object_to_boolean, a_1_b_2_c_3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import {List, Property} from './$types'; | ||
|
||
export function $remain<T>(keys: List<Property>, object: T): T; | ||
export function $manual<V>(keys: List<Property>, object: any): V; | ||
export function $<T>(keys: List<Property>, object: T): Partial<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import {Dictionary, List, Predicate} from './$types'; | ||
|
||
export function $list<T>(fn: Predicate<T>, list: List<T>): [T[], T[]]; | ||
export function $object<T, KT extends string, KF extends string>(fn: Predicate<T>, object: Record<KT | KF, T>): [Record<KT, T>, Record<KF, T>]; | ||
export function $dictionary<T>(fn: Predicate<T>, dictionary: Dictionary<T>): [Dictionary<T>, Dictionary<T>]; | ||
export function $object<T, U extends Dictionary<T>>(fn: Predicate<T>, dictionary: U): [Partial<U>, Partial<U>]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {List, Property} from './$types'; | ||
|
||
export function $remain<T>(keys: List<Property>, object: T): T; | ||
export function $manual<V>(keys: List<Property>, object: any): V; | ||
export function $pick<T, K extends keyof T>(keys: List<K>, object: T): Pick<T, K>; | ||
export function $partial<T>(keys: List<Property>, object: T): Partial<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {List, Property} from './$types'; | ||
|
||
export function $remain<T>(keys: List<Property>, object: T): T; | ||
export function $manual<V>(keys: List<Property>, object: any): V; | ||
export function $pick<T, K extends keyof T>(keys: List<K>, object: T): Pick<T, K>; | ||
export function $partial<T>(keys: List<Property>, object: T): Partial<T>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import {KeyedObjectMorphism} from './$types'; | ||
import {Dictionary, KeyedObjectMorphism} from './$types'; | ||
|
||
export function $remain<T>(fn: KeyedObjectMorphism<any, boolean, string>, object: T): T; | ||
export function $manual<V>(fn: KeyedObjectMorphism<any, boolean, string>, object: any): V; | ||
export function $<T, U extends Dictionary<T>>(fn: KeyedObjectMorphism<T, boolean, keyof U>, object: U): Partial<U>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`R_partition(number_to_boolean)(a_1_b_2_c_3) 1`] = `"[Record<string, number>, Record<string, number>]"`; | ||
exports[`R_partition(number_to_boolean)(a_1_b_2_c_3) 1`] = `"[Partial<{ a: 1; b: 2; c: 3; }>, Partial<{ a: 1; b: 2; c: 3; }>]"`; | ||
|
||
exports[`R_partition(number_to_boolean)(number_array) 1`] = `"[number[], number[]]"`; | ||
|
||
exports[`R_partition(number_to_boolean)<'a', 'b' | 'c'>(a_1_b_2_c_3) 1`] = `"[Record<\\"a\\", number>, Record<\\"b\\" | \\"c\\", number>]"`; | ||
|
||
exports[`R_partition(number_to_boolean, a_1_b_2_c_3) 1`] = `"[Record<string, number>, Record<string, number>]"`; | ||
exports[`R_partition(number_to_boolean, a_1_b_2_c_3) 1`] = `"[Partial<{ a: 1; b: 2; c: 3; }>, Partial<{ a: 1; b: 2; c: 3; }>]"`; | ||
|
||
exports[`R_partition(number_to_boolean, number_array) 1`] = `"[number[], number[]]"`; | ||
|
||
exports[`R_partition<number, 'a', 'b' | 'c'>(number_to_boolean, a_1_b_2_c_3) 1`] = `"[Record<\\"a\\", number>, Record<\\"b\\" | \\"c\\", number>]"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`R_pick([string])(object) 1`] = `"object"`; | ||
exports[`R_pick(['a', 'c'])(a_1_b_2_c_3) 1`] = `"Partial<{ a: 1; b: 2; c: 3; }>"`; | ||
|
||
exports[`R_pick([string])<Record<string, string>>(object) 1`] = `"Record<string, string>"`; | ||
exports[`R_pick(['a', 'c'], a_1_b_2_c_3) 1`] = `"Pick<{ a: 1; b: 2; c: 3; }, \\"a\\" | \\"c\\">"`; | ||
|
||
exports[`R_pick([string], object) 1`] = `"object"`; | ||
exports[`R_pick([string])(object) 1`] = `"object"`; | ||
|
||
exports[`R_pick<Record<string, string>>([string], object) 1`] = `"Record<string, string>"`; | ||
exports[`R_pick([string], object) 1`] = `"object"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`R_pickAll([string])(object) 1`] = `"object"`; | ||
exports[`R_pickAll(['a', 'c', 'f'])(a_1_b_2_c_3) 1`] = `"Partial<{ a: 1; b: 2; c: 3; }>"`; | ||
|
||
exports[`R_pickAll([string])<Record<string, string>>(object) 1`] = `"Record<string, string>"`; | ||
exports[`R_pickAll(['a', 'c', 'f'], a_1_b_2_c_3) 1`] = `"Partial<{ a: 1; b: 2; c: 3; }>"`; | ||
|
||
exports[`R_pickAll([string], object) 1`] = `"object"`; | ||
exports[`R_pickAll(['a', 'c'])(a_1_b_2_c_3) 1`] = `"Partial<{ a: 1; b: 2; c: 3; }>"`; | ||
|
||
exports[`R_pickAll(['a', 'c'], a_1_b_2_c_3) 1`] = `"Pick<{ a: 1; b: 2; c: 3; }, \\"a\\" | \\"c\\">"`; | ||
|
||
exports[`R_pickAll<Record<string, string>>([string], object) 1`] = `"Record<string, string>"`; | ||
exports[`R_pickAll([string])(object) 1`] = `"object"`; | ||
|
||
exports[`R_pickAll([string], object) 1`] = `"object"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`R_pickBy(string_string_object_to_boolean)(object) 1`] = `"object"`; | ||
exports[`R_pickBy(number_string_object_to_boolean)(a_1_b_2_c_3) 1`] = `"Partial<Dictionary<number>>"`; | ||
exports[`R_pickBy(string_string_object_to_boolean)<Record<string, string>>(object) 1`] = `"Record<string, string>"`; | ||
exports[`R_pickBy(number_string_object_to_boolean)(string_number_record) 1`] = `"Partial<Dictionary<number>>"`; | ||
exports[`R_pickBy(string_string_object_to_boolean, object) 1`] = `"object"`; | ||
exports[`R_pickBy(number_string_object_to_boolean, a_1_b_2_c_3) 1`] = `"Partial<{ a: 1; b: 2; c: 3; }>"`; | ||
exports[`R_pickBy<Record<string, string>>(string_string_object_to_boolean, object) 1`] = `"Record<string, string>"`; | ||
exports[`R_pickBy(number_string_object_to_boolean, string_number_record) 1`] = `"Partial<Record<string, number>>"`; | ||
exports[`R_pickBy(string_string_object_to_boolean)(a_1_b_2_c_3) 1`] = ` | ||
"Argument of type '{ a: 1; b: 2; c: 3; }' is not assignable to parameter of type 'Dictionary<string>'. | ||
Property 'a' is incompatible with index signature. | ||
Type '1' is not assignable to type 'string'." | ||
`; | ||
exports[`R_pickBy(string_string_object_to_boolean)(string_number_record) 1`] = ` | ||
"Argument of type 'Record<string, number>' is not assignable to parameter of type 'Dictionary<string>'. | ||
Index signatures are incompatible. | ||
Type 'number' is not assignable to type 'string'." | ||
`; | ||
exports[`R_pickBy(string_string_object_to_boolean, a_1_b_2_c_3) 1`] = `"Argument of type '{ a: 1; b: 2; c: 3; }' is not assignable to parameter of type 'Dictionary<string>'."`; | ||
exports[`R_pickBy(string_string_object_to_boolean, string_number_record) 1`] = `"Argument of type 'Record<string, number>' is not assignable to parameter of type 'Dictionary<string>'."`; |
Oops, something went wrong.