Add is.boundFunction() (#31)
This commit is contained in:
parent
89fc424975
commit
319982a09c
3 changed files with 28 additions and 1 deletions
15
readme.md
15
readme.md
|
|
@ -96,6 +96,21 @@ is.asyncFunction(() => {});
|
|||
// => false
|
||||
```
|
||||
|
||||
##### .boundFunction(value)
|
||||
|
||||
Returns `true` for any `bound` function.
|
||||
|
||||
```js
|
||||
is.boundFunction(() => {});
|
||||
// => true
|
||||
|
||||
is.boundFunction(function () {}.bind(null));
|
||||
// => true
|
||||
|
||||
is.boundFunction(function () {});
|
||||
// => false
|
||||
```
|
||||
|
||||
##### .map(value)
|
||||
##### .set(value)
|
||||
##### .weakMap(value)
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ namespace is { // tslint:disable-line:no-namespace
|
|||
|
||||
export const generatorFunction = isFunctionOfType('GeneratorFunction');
|
||||
export const asyncFunction = isFunctionOfType('AsyncFunction');
|
||||
export const boundFunction = (value: any) => function_(value) && !value.hasOwnProperty('prototype');
|
||||
|
||||
export const regExp = isObjectOfType('RegExp');
|
||||
export const date = isObjectOfType('Date');
|
||||
|
|
|
|||
|
|
@ -150,6 +150,13 @@ const types = new Map<string, Test>([
|
|||
async () => {} // tslint:disable-line:no-empty
|
||||
]
|
||||
}],
|
||||
['boundFunction', {
|
||||
is: m.boundFunction,
|
||||
fixtures: [
|
||||
() => {}, // tslint:disable-line:no-empty
|
||||
function () {}.bind(null), // tslint:disable-line:no-empty only-arrow-functions
|
||||
]
|
||||
}],
|
||||
['map', {
|
||||
is: m.map,
|
||||
fixtures: [
|
||||
|
|
@ -362,7 +369,11 @@ test('is.array', t => {
|
|||
});
|
||||
|
||||
test('is.function', t => {
|
||||
testType(t, 'function', ['generatorFunction', 'asyncFunction']);
|
||||
testType(t, 'function', ['generatorFunction', 'asyncFunction', 'boundFunction']);
|
||||
});
|
||||
|
||||
test('is.boundFunction', t => {
|
||||
t.false(m.boundFunction(function () {})); // tslint:disable-line:no-empty only-arrow-functions
|
||||
});
|
||||
|
||||
test('is.buffer', t => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue