Skip to content

Commit

Permalink
⏪ 🏷️ Revert improper typing modify in master@f6b9793
Browse files Browse the repository at this point in the history
  • Loading branch information
KsRyY committed Jan 29, 2020
1 parent 49b7e70 commit 38611fc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions src/every.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type Predicate<T> = (value: T, index?: number, list?: T[]) => boolean
type CurriedEvery<T> = (list: T[]) => boolean
type predicate<T> = (value: T, index: number, list: T[]) => boolean
type curriedEvery<T> = (list: T[]) => boolean

/**
* Returns true if all elements of the list match the predicate, false if there are any that don't. (curried) *Notice: This is not equivlant to Array.prototype.every because it uses an custom implementation that does not strictly follow the spec.*
Expand All @@ -11,7 +11,7 @@ type CurriedEvery<T> = (list: T[]) => boolean
*
* Similar to the Array.prototype.every method, the predicate will also recieve the current index and the current list as the second and the third parameter, respectively.
*/
function every<T>(predicate: Predicate<T>): CurriedEvery<T>
function every<T>(predicate: predicate<T>): curriedEvery<T>
/**
* Returns true if all elements of the list match the predicate, false if there are any that don't. *Notice: This is not equivlant to Array.prototype.every because it uses an custom implementation that does not strictly follow the spec.*
* ```js
Expand All @@ -22,11 +22,11 @@ function every<T>(predicate: Predicate<T>): CurriedEvery<T>
*
* Similar to the Array.prototype.every method, the predicate will also recieve the current index and the current list as the second and the third parameter, respectively.
*/
function every<T>(predicate: Predicate<T>, list: T[]): boolean
function every<T>(predicate: predicate<T>, list: T[]): boolean
function every<T>(
predicate: Predicate<T>,
predicate: predicate<T>,
list?: T[]
): boolean | CurriedEvery<T> {
): boolean | curriedEvery<T> {
if (list) {
let i = 0

Expand Down
14 changes: 7 additions & 7 deletions src/forEach.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
type forEachCallback<T> = (val: T, index?: number, array?: T[]) => void
type forEachCallback<T> = (val: T, index: number, array: T[]) => void

type curriedMap<T> = (array: T[]) => T[]
type curriedForEach<T> = (array: T[]) => T[]

function map<T>(cb: forEachCallback<T>): curriedMap<T>
function map<T>(cb: forEachCallback<T>, array: T[]): T[]
function map<T>(cb: forEachCallback<T>, array?: T[]): curriedMap<T> | T[] {
function forEach<T>(cb: forEachCallback<T>): curriedForEach<T>
function forEach<T>(cb: forEachCallback<T>, array: T[]): T[]
function forEach<T>(cb: forEachCallback<T>, array?: T[]): curriedForEach<T> | T[] {
if (typeof array !== 'undefined') {
array.forEach(cb)
return array
}

return array => map(cb, array)
return array => forEach(cb, array)
}

export default map
export default forEach
4 changes: 2 additions & 2 deletions src/map.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type mapCallback<ArrayMember, CallbackReturn> = (
val: ArrayMember,
index?: number,
array?: ArrayMember[]
index: number,
array: ArrayMember[]
) => CallbackReturn

type curriedMap<ArrayMember, CallbackReturn> = (
Expand Down
12 changes: 6 additions & 6 deletions src/some.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type Predicate<T> = (value: T, index?: number, list?: T[]) => boolean
type CurriedSome<T> = (list: T[]) => boolean
type predicate<T> = (value: T, index: number, list: T[]) => boolean
type curriedSome<T> = (list: T[]) => boolean

/**
* Returns true if any elements of the list match the predicate, false otherwise. (Curried)
Expand All @@ -11,7 +11,7 @@ type CurriedSome<T> = (list: T[]) => boolean
*
* Similar to the Array.prototype.some method, the predicate will also recieve the current index and the current list as the second and the third parameter, respectively.
*/
function some<T>(predicate: Predicate<T>): CurriedSome<T>
function some<T>(predicate: predicate<T>): curriedSome<T>
/**
* Returns true if any elements of the list match the predicate, false otherwise.
* ```js
Expand All @@ -22,11 +22,11 @@ function some<T>(predicate: Predicate<T>): CurriedSome<T>
* Similar to the Array.prototype.some method, the predicate will also recieve the current index and the current list as the second and the third parameter, respectively.
* ```
*/
function some<T>(predicate: Predicate<T>, list: T[]): boolean
function some<T>(predicate: predicate<T>, list: T[]): boolean
function some<T>(
predicate: Predicate<T>,
predicate: predicate<T>,
list?: T[]
): boolean | CurriedSome<T> {
): boolean | curriedSome<T> {
if (list) {
return list.some(predicate)
}
Expand Down

0 comments on commit 38611fc

Please sign in to comment.