-
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.
- Loading branch information
KsRyY
committed
Jan 28, 2020
1 parent
1d64a8c
commit def5cbd
Showing
5 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
/** | ||
* Test if the the second argument is an instance of the first argument. (curried) | ||
* ```js | ||
* instanceOf(Number)(new Number(1)) //=> true | ||
* instanceOf(Number)(1) //=> false | ||
* ``` | ||
*/ | ||
function instanceOf(a: any): (b: any) => boolean | ||
/** | ||
* Test if the the second argument is an instance of the first argument. | ||
* ```js | ||
* instanceOf(Number, new Number(1)) //=> true | ||
* instanceOf(Number, 1) //=> false | ||
* ``` | ||
*/ | ||
function instanceOf(a: any, b: any): boolean | ||
function instanceOf(a: any, b?: any): boolean | ((b: any) => boolean) { | ||
if (typeof b !== 'undefined') { | ||
return b instanceof a | ||
} | ||
|
||
return b => instanceOf(a, b) | ||
} | ||
|
||
export default instanceOf |
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 @@ | ||
/** | ||
* Test if a value is `null` or `undefined` | ||
* ```js | ||
* isEmpty(null) //=> true | ||
* isEmpty(undefined) //=> true | ||
* isEmpty(0) //=> false | ||
* isEmpty(false) //=> false | ||
* isEmpty(1) //=> false | ||
* ``` | ||
*/ | ||
const isEmpty = (operand: any): boolean => | ||
operand === null || operand === undefined | ||
|
||
export default isEmpty |
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,35 @@ | ||
/** | ||
* Test if the the second argument is an instance of the first argument. (curried) | ||
* ```js | ||
* instanceOf(Number)(new Number(1)) //=> true | ||
* instanceOf(Number)(1) //=> false | ||
* ``` | ||
*/ | ||
function join(list: Array<number | string>): (seperator: string) => string | ||
/** | ||
* Test if the the second argument is an instance of the first argument. | ||
* ```js | ||
* instanceOf(Number, new Number(1)) //=> true | ||
* instanceOf(Number, 1) //=> false | ||
* ``` | ||
*/ | ||
function join(list: Array<number | string>, seperator: string): string | ||
function join( | ||
list: Array<number | string>, | ||
seperator?: string | ||
): string | ((seperator: string) => string) { | ||
if (typeof seperator !== undefined) { | ||
let result = '' | ||
|
||
// eslint-disable-next-line unicorn/no-for-loop, @typescript-eslint/prefer-for-of | ||
for (let i = 0; i < list.length; i++) { | ||
result += `${list[i]}${seperator as string}` | ||
} | ||
|
||
return result.slice(0, -1) | ||
} | ||
|
||
return seperator => join(list, seperator) | ||
} | ||
|
||
export default join |