forked from DefinitelyTyped/DefinitelyTyped
-
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.
🤖 Merge PR DefinitelyTyped#46337 [ramda] split tests to separate modu…
…les: 'remove' - 'take' by @devrelm * move 'takeLast' tests to separate file * move 'takeLastWhile' tests to separate file * move 'takeWhile' tests to separate file * move 'tap' tests to separate file * move 'test' tests to separate file * move 'thunkify' tests to separate file * move 'times' tests to separate file * move 'toPairs' tests to separate file * move 'toPairsIn' tests to separate file * move 'toString' tests to separate file * move 'transduce' tests to separate file * move 'transpose' tests to separate file * move 'traverse' tests to separate file * move 'tryCatch' tests to separate file * move 'type' tests to separate file * move 'unapply' tests to separate file * move 'unary' tests to separate file * move 'uncurryN' tests to separate file * move 'unfold' tests to separate file * move 'uniq' tests to separate file
- Loading branch information
Showing
22 changed files
with
222 additions
and
172 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
const a: string[] = R.takeLast(1, ['foo', 'bar', 'baz']); // => ['baz'] | ||
const b: string[] = R.takeLast(2)(['foo', 'bar', 'baz']); // => ['bar', 'baz'] | ||
const c: string = R.takeLast(3, 'ramda'); // => 'mda' | ||
const d: string = R.takeLast(3)('ramda'); // => 'mda' | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
const isNotOne = (x: number) => x !== 1; | ||
const a: number[] = R.takeLastWhile(isNotOne, [1, 2, 3, 4]); // => [2, 3, 4] | ||
const b: number[] = R.takeLastWhile(isNotOne)([1, 2, 3, 4]); // => [2, 3, 4] | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
function isNotFour(x: number) { | ||
return !(x === 4); | ||
} | ||
|
||
R.takeWhile(isNotFour, [1, 2, 3, 4]); // => [1, 2, 3] | ||
R.takeWhile(isNotFour)([1, 2, 3, 4]); // => [1, 2, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
const sayX = (x: number) => console.log('x is ' + x); | ||
const a: number = R.tap(sayX, 100); // => 100 | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
const a: boolean = R.test(/^x/, 'xyz'); // => true | ||
const b: boolean = R.test(/^y/)('xyz'); // => false | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
const x: unknown = R.thunkify(R.identity)(42)(); | ||
const y: number = R.thunkify((a: number, b: number) => a + b)(25, 17)(); | ||
const z: number = R.thunkify((a: number, b: number) => a + b)(25)(17)(); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as R from 'ramda'; | ||
|
||
function i(x: number) { | ||
return x; | ||
} | ||
R.times(i, 5); | ||
|
||
() => { | ||
const a1 = R.times(R.identity, 5); // => [0, 1, 2, 3, 4] | ||
const a2 = R.times(R.identity)(5); // => [0, 1, 2, 3, 4] | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
const a = R.toPairs<number>({ a: 1, b: 2, c: 3 }); // => [['a', 1], ['b', 2], ['c', 3]] | ||
const b = R.toPairs({ 1: 'a' }); // => [['1', 'something']] | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as R from 'ramda'; | ||
|
||
class F { | ||
[k: string]: string; | ||
x = 'X'; | ||
y = 'Y'; | ||
} | ||
|
||
() => { | ||
const f = new F(); | ||
const a1 = R.toPairsIn(f); // => [['x','X'], ['y','Y']] | ||
const a2 = R.toPairsIn<string>(f); // => [['x','X'], ['y','Y']] | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
class Point { | ||
constructor(public x: number, public y: number) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
toStringn() { | ||
return `new Point(${this.x}, ${this.y})`; | ||
} | ||
} | ||
R.toString(new Point(1, 2)); // => 'new Point(1, 2)' | ||
|
||
R.toString(42); // => '42' | ||
R.toString('abc'); // => '"abc"' | ||
R.toString([1, 2, 3]); // => '[1, 2, 3]' | ||
R.toString({ foo: 1, bar: 2, baz: 3 }); // => '{"bar": 2, "baz": 3, "foo": 1}' | ||
R.toString(new Date('2001-02-03T04:05:06Z')); // => 'new Date("2001-02-03T04:05:06.000Z")' | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
const numbers = [1, 2, 3, 4]; | ||
const transducer = R.compose( | ||
R.map(R.add(1)), | ||
R.take(2), | ||
); | ||
const fn = R.flip<number, number[], number[]>(R.append); | ||
R.transduce(transducer, fn, [], numbers); // => [2, 3] | ||
R.transduce(transducer, fn, [])(numbers); // => [2, 3] | ||
R.transduce(transducer, fn)([], numbers); // => [2, 3] | ||
R.transduce<number, number>(transducer)(fn, [], numbers); // => [2, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
const a: Array<Array<number | string>> = R.transpose<number | string>([ | ||
[1, 'a'], | ||
[2, 'b'], | ||
[3, 'c'], | ||
]); // => [[1, 2, 3], ['a', 'b', 'c']] | ||
const b: Array<Array<number | string>> = R.transpose<number | string>([ | ||
[1, 2, 3], | ||
['a', 'b', 'c'], | ||
]); // => [[1, 'a'], [2, 'b'], [3, 'c']] | ||
const c: number[][] = R.transpose([[10, 11], [20], [], [30, 31, 32]]); // => [[10, 20, 30], [11, 31], [32]] | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
const of = Array.of; | ||
const fn = (x: number) => Array.of(x + 1); | ||
const list = [1, 2, 3]; | ||
R.traverse(of, fn, list); | ||
R.traverse(of, fn)(list); | ||
R.traverse<number, number>(of)(fn, list); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
const a: boolean = R.tryCatch<boolean>(R.prop('x'), R.F)({ x: true }); // => true | ||
const a1: boolean = R.tryCatch(R.prop<'x', true>('x'), R.F)({ x: true }); // => true | ||
const b: boolean = R.tryCatch<boolean>(R.prop('x'), R.F)(null); // => false | ||
const c: boolean = R.tryCatch<boolean>(R.and, R.F)(true, true); // => true | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
R.type({}); // => "Object" | ||
R.type(1); // => "Number" | ||
R.type(false); // => "Boolean" | ||
R.type('s'); // => "String" | ||
R.type(null); // => "Null" | ||
R.type([]); // => "Array" | ||
R.type(/[A-z]/); // => "RegExp" | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import * as R from 'ramda'; | ||
|
||
() => { | ||
const fn: (...args: string[]) => string = R.unapply(JSON.stringify); | ||
const res: string = R.unapply(JSON.stringify)(1, 2, 3); // => '[1,2,3]' | ||
}; |
Oops, something went wrong.