mirror of
https://github.com/flynx/types.js.git
synced 2025-10-28 10:00:08 +00:00
exposed AsyncFunction constructor in Function.js...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
95504c27c5
commit
cc9824c9a9
9
Array.js
9
Array.js
@ -212,9 +212,12 @@ object.Mixin('ArrayMixin', 'soft', {
|
||||
// done...
|
||||
: [] },
|
||||
|
||||
// XXX add handler function support -- a-la generator.js'
|
||||
iter: function*(lst=[]){
|
||||
yield* lst.iter() },
|
||||
// XXX not sure about the handler API here yet...
|
||||
iter: function*(lst=[], handler=undefined){
|
||||
yield* lst.iter(
|
||||
...(handler ?
|
||||
[handler]
|
||||
: [])) },
|
||||
})
|
||||
|
||||
|
||||
|
||||
18
Function.js
Normal file
18
Function.js
Normal file
@ -0,0 +1,18 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
**********************************************/ /* c8 ignore next 2 */
|
||||
((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define)
|
||||
(function(require){ var module={} // make module AMD/node compatible...
|
||||
/*********************************************************************/
|
||||
|
||||
|
||||
var AsyncFunction =
|
||||
module.AsyncFunction =
|
||||
(async function(){}).constructor
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* vim:set ts=4 sw=4 : */ return module })
|
||||
26
README.md
26
README.md
@ -13,6 +13,8 @@ Library of JavaScript type extensions, types and utilities.
|
||||
- [`Object.matchPartial(..)`](#objectmatchpartial)
|
||||
- [`<object>.run(..)`](#objectrun)
|
||||
- [`Object.sort(..)`](#objectsort)
|
||||
- [`Function`](#function)
|
||||
- [`func.AsyncFunction`](#funcasyncfunction)
|
||||
- [`Array`](#array)
|
||||
- [`<array>.first(..)` / `<array>.last(..)`](#arrayfirst--arraylast)
|
||||
- [`<array>.rol(..)`](#arrayrol)
|
||||
@ -454,6 +456,30 @@ Object.keys(Object.sort(o, ['x', 'a', '100']))
|
||||
This is similar to [`<map>.sort(..)`](#mapsort) and [`<ser>.sort(..)`](#setsort).
|
||||
|
||||
|
||||
## `Function`
|
||||
|
||||
```javascript
|
||||
var func = require('ig-types/Function')
|
||||
```
|
||||
|
||||
### `func.AsyncFunction`
|
||||
|
||||
The async function constructor.
|
||||
|
||||
This enables us to test if an object is an instance of an async function.
|
||||
|
||||
```javascript
|
||||
var a = async function(){
|
||||
// ...
|
||||
}
|
||||
|
||||
a instanceof func.AsyncFunction // -> true
|
||||
```
|
||||
|
||||
This is hidden by JavaScript by default.
|
||||
|
||||
|
||||
|
||||
## `Array`
|
||||
|
||||
```javascript
|
||||
|
||||
3
main.js
3
main.js
@ -22,6 +22,7 @@ module.patchDate = require('./Date').patchDate
|
||||
|
||||
// Additional types...
|
||||
module.containers = require('./containers')
|
||||
module.func = require('./Function')
|
||||
module.generator = require('./generator')
|
||||
module.event = require('./event')
|
||||
module.runner = require('./runner')
|
||||
@ -31,7 +32,9 @@ module.runner = require('./runner')
|
||||
module.STOP = object.STOP
|
||||
|
||||
// frequently used stuff...
|
||||
module.AsyncFunction = module.func.AsyncFunction
|
||||
module.Generator = module.generator.Generator
|
||||
module.AsyncGenerator = module.generator.AsyncGenerator
|
||||
// XXX doc...
|
||||
module.iter = module.generator.iter
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-types",
|
||||
"version": "6.15.6",
|
||||
"version": "6.15.7",
|
||||
"description": "Generic JavaScript types and type extensions...",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user