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
|
// => 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)
|
##### .map(value)
|
||||||
##### .set(value)
|
##### .set(value)
|
||||||
##### .weakMap(value)
|
##### .weakMap(value)
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ namespace is { // tslint:disable-line:no-namespace
|
||||||
|
|
||||||
export const generatorFunction = isFunctionOfType('GeneratorFunction');
|
export const generatorFunction = isFunctionOfType('GeneratorFunction');
|
||||||
export const asyncFunction = isFunctionOfType('AsyncFunction');
|
export const asyncFunction = isFunctionOfType('AsyncFunction');
|
||||||
|
export const boundFunction = (value: any) => function_(value) && !value.hasOwnProperty('prototype');
|
||||||
|
|
||||||
export const regExp = isObjectOfType('RegExp');
|
export const regExp = isObjectOfType('RegExp');
|
||||||
export const date = isObjectOfType('Date');
|
export const date = isObjectOfType('Date');
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,13 @@ const types = new Map<string, Test>([
|
||||||
async () => {} // tslint:disable-line:no-empty
|
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', {
|
['map', {
|
||||||
is: m.map,
|
is: m.map,
|
||||||
fixtures: [
|
fixtures: [
|
||||||
|
|
@ -362,7 +369,11 @@ test('is.array', t => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('is.function', 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 => {
|
test('is.buffer', t => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue