new Aigle(executor)
Create a new promise instance. It is same as native Promise.
It has three states, pending
, fulfilled
and rejected
, the first state is pending
.
The passed function has resolve
and reject
as the arguments,
if reject
is called or an error is caused, the state goes to rejected
and then the error is thrown to next catch
.
If request is success and resolve
is called, then
or next task is called.
Example
return new Promise((resolve, reject) => {
fs.readFile('filepath', (err, data) => {
if (err) {
return reject(err);
}
resolve(data);
});
})
.then(data => ...)
.catch(err => ...);
Parameters:
Name | Type | Description |
---|---|---|
executor |
function |
Methods
all() → {Aigle}
Aigle#all
will execute Aigle.all
using a previous promise value.
The value will be assigned as the first argument to Aigle.all
.
Example
const order = [];
const makeDelay = (num, delay) => {
return Aigle.delay(delay)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve([
makeDelay(1, 30),
makeDelay(2, 20),
makeDelay(3, 10)
])
.all()
.then(array => {
console.log(array); // [1, 2, 3];
console.log(order); // [3, 2, 1];
});
Returns:
Returns an Aigle instance
- Type
- Aigle
cancel()
Example
const { CancellationError } = Aigle;
let cancelled = false;
const promise = new Aigle((resolve, reject, onCancel) => {
setTimeout(resolve, 30, 'resolved');
onCancel(() => cancelled = true);
});
promise.cancel();
promise.catch(error => {
console.log(error instanceof CancellationError); // true
console.log(cancelled); // true
});
catch(onRejected) → {Aigle}
Example
return Aigle.reject(new TypeError('error'))
.catch(TypeError, error => console.log(error));
Parameters:
Name | Type | Description |
---|---|---|
onRejected |
Object | function |
Returns:
Returns an Aigle instance
- Type
- Aigle
concat(iterator)
Aigle#concat
will execute Aigle.concat
using a previous promise value and a defined iterator.
The value will be assigned as the first argument to Aigle.concat
and
the iterator will be assigned as the second argument.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (num, index, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.concat(iterator)
.then(array => {
console.log(array); // [1, 2, 4];
console.log(order); // [1, 2, 4];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (num, key, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.concat(iterator)
.then(array => {
console.log(array); // [1, 2, 4];
console.log(order); // [1, 2, 4];
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
concatLimit(limitopt, iterator)
Aigle#concatLimit
is almost the same as Aigle#concat
and Aigle#concatSeries
), but it will work with concurrency.
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.concatLimit(2, iterator)
.then(array => {
console.log(array); // [1, 3, 5, 2, 4];
console.log(order); // [1, 3, 5, 2, 4];
});
const order = [];
const collection = {
task1: 1,
task2: 5,
task3: 3,
task4: 4,
task5: 2
};
const iterator = (num, key, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.concatLimit(2, iterator)
.then(array => {
console.log(array); // [1, 3, 5, 2, 4];
console.log(order); // [1, 3, 5, 2, 4];
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.concatLimit(iterator)
.then(array => {
console.log(array); // [1, 3, 5, 2, 4];
console.log(order); // [1, 3, 5, 2, 4];
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
integer |
<optional> |
8
|
|
iterator |
function |
concatSeries(iterator)
Aigle#concatSeries
is almost the same as Aigle#concat
, but it will work in series.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (num, index, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.concatSeries(iterator)
.then(array => {
console.log(array); // [1, 4, 2];
console.log(order); // [1, 4, 2];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (num, key, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.concatSeries(iterator)
.then(array => {
console.log(array); // [1, 4, 2];
console.log(order); // [1, 4, 2];
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
delay(ms)
After a previous promise is resolved, the timer will be started with ms
.
After ms
, the delay's promise will be resolved with the previous promise value.
Examples
Aigle.resolve()
.delay(10)
.then(value => console.log(value); // undefined
Aigle.resolve('test')
.delay(10)
.then(value => console.log(value); // 'test'
Parameters:
Name | Type | Description |
---|---|---|
ms |
number |
disposer(handler)
Parameters:
Name | Type | Description |
---|---|---|
handler |
function |
doUntil(iterator, tester)
Example
const order = [];
const tester = num => {
order.push(`t:${num}`);
return Aigle.delay(10)
.then(() => num === 4);
};
const iterator = count => {
const num = ++count;
order.push(`i:${num}`);
return Aigle.delay(10)
.then(() => num);
};
Aigle.resolve(0)
.doUntil(iterator, tester)
.then(value => {
console.log(value); // 4
console.log(order); // [ 'i:1', 't:1', 'i:2', 't:2', 'i:3', 't:3', 'i:4', 't:4' ]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | |
tester |
function |
doWhilst(iterator, tester)
Example
const order = [];
const tester = num => {
order.push(`t:${num}`);
return Aigle.delay(10)
.then(() => num !== 4);
};
const iterator = count => {
const num = ++count;
order.push(`i:${num}`);
return Aigle.delay(10)
.then(() => num);
};
Aigle.resolve(0)
.doWhilst(iterator, tester)
.then(value => {
console.log(value); // 4
console.log(order); // [ 'i:1', 't:1', 'i:2', 't:2', 'i:3', 't:3', 'i:4', 't:4' ]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | |
tester |
function |
each(iterator)
Aigle#each
will execute Aigle.each
using a previous promise value and a defined iterator.
The value will be assigned as the first argument to Aigle.each
and
the iterator will be assigned as the second argument.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (num, value, collection) => {
return Aigle.delay(num * 10)
.then(() => order.push(num));
};
return Aigle.resolve(collection)
.each(iterator)
.then(value => {
console.log(value); // undefined
console.log(order); // [1, 2, 4];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (num, key, collection) => {
return Aigle.delay(num * 10)
.then(() => order.push(num));
};
return Aigle.resolve(collection)
.each(iterator)
.then(value => {
console.log(value); // undefined
console.log(order); // [1, 2, 4];
});
const order = [];
const collection = [1, 4, 2];
const iterator = (num, value, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num !== 2; // break
});
};
return Aigle.resolve(collection)
.each(iterator)
.then(value => {
console.log(value); // undefined
console.log(order); // [1, 2];
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
eachLimit(limitopt, iterator) → {Aigle}
Aigle#eachLimit
is almost the same as Aigle.each
and
Aigle.eachSeries
, but it will work with concurrency.
Examples
const collection = [1, 5, 3, 4, 2];
return Aigle.resolve(collection)
.eachLimit(2, (num, index, collection) => {
return new Aigle(resolve => setTimeout(() => {
console.log(num); // 1, 3, 5, 2, 4
resolve(num);
}, num * 10));
});
const collection = [1, 5, 3, 4, 2];
return Aigle.resolve(collection)
.eachLimit((num, index, collection) => {
return new Aigle(resolve => setTimeout(() => {
console.log(num); // 1, 2, 3, 4, 5
resolve(num);
}, num * 10));
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
eachSeries(iterator)
Aigle#eachSeries
is almost the same as Aigle#each
, but it will work in series.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (num, index, collection) => {
return Aigle.delay(num * 10)
.then(() => order.push(num));
};
Aigle.resolve(collection)
.eachSeries(iterator)
.then(value => {
console.log(value); // undefined
console.log(order); // [1, 4, 2];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (num, index, collection) => {
return Aigle.delay(num * 10)
.then(() => order.push(num));
};
Aigle.resolve(collection)
.eachSeries(iterator)
.then(value => {
console.log(value); // undefined
console.log(order); // [1, 4, 2];
});
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num !== 4; // break
});
};
Aigle.resolve(collection)
.eachSeries(iterator)
.then(value => {
console.log(value); // undefined
console.log(order); // [1, 4];
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
every(iterator) → {Aigle}
Aigle#every
will execute Aigle.every
using a previous promise value and a defined iterator.
The value will be assigned as the first argument to Aigle.every
and
the iterator will be assigned as the second argument.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (num, index, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return true;
});
};
Aigle.resolve(collection)
.every(iterator)
.then(value => {
console.log(value); // true
console.log(order); // [1, 2, 4];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (num, key, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return true;
});
};
Aigle.resolve(collection)
.every(iterator)
.then(value => {
console.log(value); // true
console.log(order); // [1, 2, 4];
});
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return n % 2;
});
};
Aigle.resolve(collection)
.every(iterator)
.then(value => {
console.log(value); // false
console.log(order); // [1, 2];
});
const collection = [{
uid: 1, active: false
}, {
uid: 4, active: true
}, {
uid: 2, active: true
}];
Aigle.resolve(collection)
.every('active')
.then(value => console.log(value)); // false
const collection = [{
uid: 1, active: false
}, {
uid: 4, active: true
}, {
uid: 2, active: true
}];
Aigle.resolve(collection)
.every('active')
.then(value => console.log(value)); // false
const collection = [{
uid: 1, active: false
}, {
uid: 4, active: true
}, {
uid: 2, active: true
}];
Aigle.resolve(collection)
.every(['active', true])
.then(value => console.log(value)); // false
const collection = [{
uid: 1, active: true
}, {
uid: 4, active: true
}, {
uid: 2, active: true
}];
Aigle.resolve(collection)
.every({ active: true })
.then(value => console.log(value)); // true
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | Array | Object | string |
Returns:
Returns an Aigle instance
- Type
- Aigle
everyLimit(limitopt, iterator) → {Aigle}
Aigle#everyLimit
is almost the same as Aigle#every
and
Aigle#everySeries
, but it will work with concurrency.
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return true;
});
};
Aigle.resolve(collection)
.everyLimit(2, iterator)
.then(value => {
console.log(value); // true
console.log(order); // [1, 3, 5, 2, 4];
});
const order = [];
const collection = {
task1: 1,
task2: 5,
task3: 3,
task4: 4,
task5: 2
};
const iterator = (num, key, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return true;
});
};
Aigle.resolve(collection)
.everyLimit(2, iterator)
.then(value => {
console.log(value); // true
console.log(order); // [1, 3, 5, 2, 4];
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num === 4;
});
};
Aigle.resolve(collection)
.everyLimit(iterator)
.then(value => {
console.log(value); // false
console.log(order); // [1, 2, 3, 4];
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
everySeries(iterator) → {Aigle}
Aigle#everySeries
is almost the same as Aigle#every
, but it will work in series.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (num, index, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return true;
});
};
Aigle.resolve(collection)
.everySeries(iterator)
.then(value => {
console.log(value); // true
console.log(order); // [1, 4, 2];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (num, key, collection) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return true;
});
};
Aigle.resolve(collection)
.everySeries(iterator)
.then(value => {
console.log(value); // true
console.log(order); // [1, 4, 2];
});
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return n % 2;
});
};
Aigle.resolve(collection)
.everySeries(iterator)
.then(value => {
console.log(value); // false
console.log(order); // [1, 4];
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
filter(iterator) → {Aigle}
Aigle#filter
will execute Aigle.filter
using a previous promise value and a defined iterator.
The value will be assigned as the first argument to Aigle.filter
and
the iterator will be assigned as the second argument.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.filter(iterator)
.then(array => {
console.log(array); // [1];
console.log(order); // [1, 2, 4];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.filter(iterator)
.then(array => {
console.log(array); // [1];
console.log(order); // [1, 2, 4];
});
const order = [];
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.filter('active')
.then(array => {
console.log(array); // [{ name: 'fread', active: true }]
});
const order = [];
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.filter(['name', 'fread'])
.then(array => {
console.log(array); // [{ name: 'fread', active: true }]
});
const order = [];
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.filter({ name: 'fread', active: true })
.then(array => {
console.log(array); // [{ name: 'fread', active: true }]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | Array | Object | string |
Returns:
Returns an Aigle instance
- Type
- Aigle
filterLimit(limitopt, iterator) → {Aigle}
Aigle#filterLimit
is almost the same as Aigle#filter
and Aigle#filterSeries
), but it will work with concurrency.
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.filterLimit(2, iterator)
.then(array => {
console.log(array); // [1, 5, 3];
console.log(order); // [1, 3, 5, 2, 4];
});
const order = [];
const collection = {
task1: 1,
task2: 5,
task3: 3,
task4: 4,
task5: 2
};
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.filterLimit(2, iterator)
.then(array => {
console.log(array); // [1, 5, 3];
console.log(order); // [1, 3, 5, 2, 4];
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.filterLimit(iterator)
.then(array => {
console.log(array); // [1, 5, 3];
console.log(order); // [1, 2, 3, 4, 5];
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
integer |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
filterSeries(iterator) → {Aigle}
Aigle#filterSeries
is almost the same as Aigle#filter
, but it will work in series.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.filterSeries(iterator)
.then(array => {
console.log(array); // [1];
console.log(order); // [1, 4, 2];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.filterSeries(iterator)
.then(array => {
console.log(array); // [1];
console.log(order); // [1, 4, 2];
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
finally(handler) → {Aigle}
Parameters:
Name | Type | Description |
---|---|---|
handler |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
find(iterator) → {Aigle}
Aigle#find
will execute Aigle.find
using a previous promise value and a defined iterator.
The value will be assigned as the first argument to Aigle.find
and
the iterator will be assigned as the second argument.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.find(iterator)
.then(value => {
console.log(value); // 2
console.log(order); // [1, 2];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.find(iterator)
.then(value => {
console.log(value); // 2
console.log(order); // [1, 2];
});
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return false;
});
};
Aigle.resolve(collection)
.find(iterator)
.then(value => {
console.log(value); // undefined
console.log(order); // [1, 2, 4];
});
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.find('active')
.then(object => {
console.log(object); // { name: 'fread', active: true }
});
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.find(['name', 'fread'])
.then(object => {
console.log(object); // { name: 'fread', active: true }
});
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.find({ name: 'fread', active: true })
.then(object => {
console.log(object); // { name: 'fread', active: true }
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | Array | Object | string |
Returns:
Returns an Aigle instance
- Type
- Aigle
findIndex(iterator) → {Aigle}
Aigle#findIndex
will execute Aigle.findIndex
using a previous promise value and a defined iterator.
The value will be assigned as the first argument to Aigle.findIndex
and
the iterator will be assigned as the second argument.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.findIndex(iterator)
.then(index => {
console.log(index); // 2
console.log(order); // [1, 2];
});
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return false;
});
};
Aigle.resolve(collection)
.findIndex(iterator)
.then(index => {
console.log(index); // -1
console.log(order); // [1, 2, 4];
});
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.findIndex('active')
.then(index => {
console.log(index); // 1
});
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.findIndex(['name', 'fread'])
.then(index => {
console.log(index); // 1
});
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.findIndex({ name: 'fread', active: true })
.then(index => {
console.log(index); // 1
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | Array | Object | string |
Returns:
Returns an Aigle instance
- Type
- Aigle
findIndexLimit(limitopt, iterator) → {Aigle}
Aigle#findIndexLimit
is almost the same as Aigle#findIndex
and Aigle#findIndexSeries
), but it will work with concurrency.
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.findIndexLimit(2, iterator)
.then(index => {
console.log(index); // 4
console.log(order); // [1, 3, 5, 2];
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.findIndexLimit(2, iterator)
.then(index => {
console.log(index); // 4
console.log(order); // [1, 2];
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
integer |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
findIndexSeries(iterator) → {Aigle}
Aigle#findIndexSeries
is almost the same as Aigle#findIndex
, but it will work in series.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.findIndexSeries(iterator)
.then(index => {
console.log(index); // 2
console.log(order); // [1, 4];
});
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return false;
});
};
Aigle.resolve(collection)
.findIndexSeries(iterator)
.then(index => {
console.log(index); // -1
console.log(order); // [1, 4, 2];
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
findKey(iterator) → {Aigle}
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
findKeyLimit(limitopt, iterator) → {Aigle}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
integer |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
findKeySeries(iterator) → {Aigle}
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
findLimit(limitopt, iterator) → {Aigle}
Aigle#findLimit
is almost the same as Aigle#find
and Aigle#findSeries
), but it will work with concurrency.
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.findLimit(2, iterator)
.then(value => {
console.log(value); // 2
console.log(order); // [1, 3, 5, 2];
});
const order = [];
const collection = {
task1: 1,
task2: 5,
task3: 3,
task4: 4,
task5: 2
};
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.findLimit(2, iterator)
.then(value => {
console.log(value); // 2
console.log(order); // [1, 3, 5, 2];
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.findLimit(2, iterator)
.then(value => {
console.log(value); // 2
console.log(order); // [1, 2];
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
integer |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
findSeries(iterator) → {Aigle}
Aigle#findSeries
is almost the same as Aigle#find
, but it will work in series.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.findSeries(iterator)
.then(value => {
console.log(value); // 4
console.log(order); // [1, 4];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.findSeries(iterator)
.then(value => {
console.log(value); // 4
console.log(order); // [1, 4];
});
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return false;
});
};
Aigle.resolve(collection)
.findSeries(iterator)
.then(value => {
console.log(value); // undefined
console.log(order); // [1, 4, 2];
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
groupBy(iterator) → {Aigle}
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.groupBy(iterator)
.then(object => {
console.log(object); // { '0': [2, 4], '1': [1] };
console.log(order); // [1, 2, 4];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.groupBy(iterator)
.then(object => {
console.log(object); // { '0': [2, 4], '1': [1] };
console.log(order); // [1, 2, 4];
});
const order = [];
const collection = ['one', 'two', 'three'];
Aigle.resolve(collection)
.groupBy('length')
.then(object => {
console.log(object); // { '3': ['one', 'two'], '5': ['three'] };
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | string |
Returns:
Returns an Aigle instance
- Type
- Aigle
groupByLimit(limitopt, iterator) → {Aigle}
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.groupByLimit(2, iterator)
.then(object => {
console.log(object); // { '0': [2, 4], '1': [1, 3, 5] };
console.log(order); // [1, 3, 5, 2, 4];
});
const order = [];
const collection = {
task1: 1,
task2: 5,
task3: 3,
task4: 4,
task5: 2
};
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.groupByLimit(2, iterator)
.then(object => {
console.log(object); // { '0': [2, 4], '1': [1, 3, 5] };
console.log(order); // [1, 3, 5, 2, 4];
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.groupByLimit(iterator)
.then(object => {
console.log(object); // { '0': [2, 4], '1': [1, 3, 5] };
console.log(order); // [1, 2, 3, 4, 5];
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
groupBySeries(iterator) → {Aigle}
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.groupBySeries(iterator)
.then(object => {
console.log(object); // { '0': [4, 2], '1': [1] };
console.log(order); // [1, 4, 2];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.groupBySeries(iterator)
.then(object => {
console.log(object); // { '0': [4, 2], '1': [1] };
console.log(order); // [1, 4, 2];
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
isCancelled() → {boolean}
Returns:
- Type
- boolean
isFulfilled() → {boolean}
Returns:
- Type
- boolean
isPending() → {boolean}
Returns:
- Type
- boolean
isRejected() → {boolean}
Returns:
- Type
- boolean
map(iterator) → {Aigle}
Aigle#map
will execute Aigle.map
using a previous promise value and a defined iterator.
The value will be assigned as the first argument to Aigle.map
and
the iterator will be assigned as the second argument.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.map(iterator)
.then(array => {
console.log(array); // [2, 8, 4]
console.log(order); // [1, 2, 4]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.map(iterator)
.then(array => {
console.log(array); // [2, 8, 4]
console.log(order); // [1, 2, 4]
});
const collection = [{
uid: 1, name: 'test1'
}, {
uid: 4, name: 'test4'
}, {
uid: 2, name: 'test2'
}];
Aigle.resolve(collection)
.map('uid')
.then(uids => console.log(uids)); // [1, 4, 2]
const collection = {
task1: { uid: 1, name: 'test1' },
task2: { uid: 4, name: 'test4' },
task3: { uid: 2, name: 'test2' }
}];
Aigle.resolve(collection)
.map('uid')
.then(uids => console.log(uids)); // [1, 4, 2]
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | string | if you define string, you can use shorthand which is similar to lodash |
Returns:
Returns an Aigle instance
- Type
- Aigle
mapLimit(limitopt, iterator) → {Aigle}
Aigle#mapLimit
is almost the same as Aigle#map
and Aigle#mapSeries
), but it will work with concurrency.
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.mapLimit(2, iterator)
.then(array => {
console.log(array); // [2, 10, 6, 8, 4];
console.log(order); // [1, 3, 5, 2, 4];
});
const order = [];
const collection = {
task1: 1,
task2: 5,
task3: 3,
task4: 4,
task5: 2
};
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.mapLimit(2, iterator)
.then(array => {
console.log(array); // [2, 10, 6, 8, 4];
console.log(order); // [1, 3, 5, 2, 4];
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.mapLimit(iterator)
.then(array => {
console.log(array); // [2, 10, 6, 8, 4];
console.log(order); // [1, 2, 3, 4, 5];
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
integer |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
mapSeries(iterator) → {Aigle}
Aigle#mapSeries
is almost the same as Aigle#map
, but it will work in series.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.mapSeries(iterator)
.then(array => {
console.log(array); // [2, 8, 4]
console.log(order); // [1, 4, 2]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.mapSeries(iterator)
.then(array => {
console.log(array); // [2, 8, 4]
console.log(order); // [1, 4, 2]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
mapValues(iterator) → {Aigle}
Aigle#mapValues
will execute Aigle.mapValues
using a previous promise value and a defined iterator.
The value will be assigned as the first argument to Aigle.mapValues
and
the iterator will be assigned as the second argument.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.mapValues(iterator)
.then(object => {
console.log(object); // { '0': 2, '1': 8, '2': 4 }
console.log(order); // [1, 2, 4]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.mapValues(iterator)
.then(object => {
console.log(object); // { a: 2, b: 8, c: 4 }
console.log(order); // [1, 2, 4]
});
const collection = [{
uid: 1, name: 'test1'
}, {
uid: 4, name: 'test4'
}, {
uid: 2, name: 'test2'
}];
Aigle.resolve(collection)
.mapValues('uid')
.then(uids => console.log(uids)); // { '0': 1, '1': 4, '2': 2 }
const collection = {
task1: { uid: 1, name: 'test1' },
task2: { uid: 4, name: 'test4' },
task3: { uid: 2, name: 'test2' }
}];
Aigle.resolve(collection)
.mapValues('uid')
.then(uids => console.log(uids)); // { task1: 1, task2: 4, task3: 2 }
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | string | if you define string, you can use shorthand which is similar to lodash |
Returns:
Returns an Aigle instance
- Type
- Aigle
mapValuesLimit(limitopt, iterator) → {Aigle}
Aigle#mapValuesLimit
is almost the same as Aigle#mapValues
and Aigle#mapValuesSeries
), but it will work with concurrency.
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.mapValuesLimit(2, iterator)
.then(object => {
console.log(object); // { '0': 2, '1': 10, '2': 6, '3': 8, '4': 4 }
console.log(order); // [1, 3, 5, 2, 4]
});
const order = [];
const collection = { a: 1, b: 5, c: 3, d: 4, e: 2 };
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.mapValuesLimit(2, iterator)
.then(object => {
console.log(object); // { a: 2, b: 10, c: 6, d: 8, e: 4 }
console.log(order); // [1, 3, 5, 2, 4]
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.mapValuesLimit(iterator)
.then(object => {
console.log(object); // { '0': 2, '1': 10, '2': 6, '3': 8, '4': 4 }
console.log(order); // [1, 2, 3, 4, 5]
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
mapValuesSeries(iterator) → {Aigle}
Aigle#mapValuesSeries
is almost the same as Aigle#mapValues
, but it will work in series.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.mapValuesSeries(iterator)
.then(object => {
console.log(object); // { '0': 2, '1': 8, '2': 4 }
console.log(order); // [1, 4, 2]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.mapValuesSeries(iterator)
.then(object => {
console.log(object); // { a: 2, b: 8, c: 4 }
console.log(order); // [1, 4, 2]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
omit(iterator, …argsopt) → {Aigle}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
iterator |
* | ||
args |
* |
<optional> <repeatable> |
Returns:
Returns an Aigle instance
- Type
- Aigle
omitBy(iterator) → {Aigle}
Aigle#omitBy
will execute Aigle.omitBy
using a previous promise value and a defined iterator.
The value will be assigned as the first argument to Aigle.omitBy
and
the iterator will be assigned as the second argument.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.omitBy(iterator)
.then(object => {
console.log(object); // { '1': 4, '2': 4 }
console.log(order); // [1, 2, 4]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.omitBy(iterator)
.then(object => {
console.log(object); // { b: 4, c: 2 }
console.log(order); // [1, 2, 4]
});
const order = [];
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.omitBy('active')
.then(object => {
console.log(object); // { '0': { name: 'bargey', active: false } }
});
const order = [];
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.omitBy(['name', 'fread'])
.then(object => {
console.log(object); // { '0': { name: 'bargey', active: false } }
});
const order = [];
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.omitBy({ name: 'fread', active: true })
.then(object => {
console.log(object); // { '0': { name: 'bargey', active: false } }
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | Array | Object | string |
Returns:
Returns an Aigle instance
- Type
- Aigle
omitByLimit(limitopt, iterator) → {Aigle}
Aigle#omitByLimit
is almost the same as Aigle#omitBy
and Aigle#omitBySeries
), but it will work with concurrency.
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.omitByLimit(2, iterator)
.then(object => {
console.log(object); // { '3': 4, '4': 2 }
console.log(order); // [1, 3, 5, 2, 4]
});
const order = [];
const collection = { a: 1, b: 5, c: 3, d: 4, e: 2 };
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.omitByLimit(2, iterator)
.then(object => {
console.log(object); // { d: 4, e: 2 }
console.log(order); // [1, 3, 5, 2, 4]
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.omitByLimit(iterator)
.then(object => {
console.log(object); // { '3': 4, '4': 2 }
console.log(order); // [1, 2, 3, 4, 5]
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
omitBySeries(iterator) → {Aigle}
Aigle#omitBySeries
is almost the same as Aigle#omitBy
, but it will work in series.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.omitBySeries(iterator)
.then(object => {
console.log(object); // { '1': 4, '2': 4 }
console.log(order); // [1, 4, 2]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.omitBySeries(iterator)
.then(object => {
console.log(object); // { b: 4, c: 2 }
console.log(order); // [1, 4, 2]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
parallel()
Aigle#parallel
will execute Aigle.parallel
using a previous promise value.
The value will be assigned as the first argument to Aigle.parallel
.
Examples
Aigle.resolve([
() => Aigle.delay(30, 1),
Aigle.delay(20, 2),
3
])
.parallel()
.then(array => {
console.log(array); // [1, 2, 3]
});
Aigle.resolve({
a: () => Aigle.delay(30, 1),
b: Aigle.delay(20, 2),
c: 3
})
.parallel()
.then(object => {
console.log(object); // { a: 1, b: 2, c: 3 }
});
parallelLimit(limitopt)
Aigle#parallelLimit
has the same functionality as Aigle#parallel
and it works with concurrency.
Examples
Aigle.resolve([
() => Aigle.delay(30, 1),
Aigle.delay(20, 2),
3
])
.parallelLimit()
.then(array => {
console.log(array); // [1, 2, 3]
});
Aigle.resolve({
a: () => Aigle.delay(30, 1),
b: Aigle.delay(20, 2),
c: 3
})
.parallelLimit(2)
.then(object => {
console.log(object); // { a: 1, b: 2, c: 3 }
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number |
<optional> |
8
|
pick(iterator, …argsopt) → {Aigle}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
iterator |
* | ||
args |
* |
<optional> <repeatable> |
Returns:
Returns an Aigle instance
- Type
- Aigle
pickBy(iterator) → {Aigle}
Aigle#pickBy
will execute Aigle.pickBy
using a previous promise value and a defined iterator.
The value will be assigned as the first argument to Aigle.pickBy
and
the iterator will be assigned as the second argument.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.pickBy(iterator)
.then(object => {
console.log(object); // { '0': 1 }
console.log(order); // [1, 2, 4]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.pickBy(iterator)
.then(object => {
console.log(object); // { a: 1 }
console.log(order); // [1, 2, 4]
});
const order = [];
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.pickBy('active')
.then(object => {
console.log(object); // { '1': { name: 'fread', active: true } }
});
const order = [];
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.pickBy(['name', 'fread'])
.then(object => {
console.log(object); // { '1': { name: 'fread', active: true } }
});
const order = [];
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.resolve(collection)
.pickBy({ name: 'fread', active: true })
.then(object => {
console.log(object); // { '1': { name: 'fread', active: true } }
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | string |
Returns:
Returns an Aigle instance
- Type
- Aigle
pickByLimit(limitopt, iterator) → {Aigle}
Aigle#pickByLimit
is almost the same as Aigle#pickBy
and Aigle#pickBySeries
), but it will work with concurrency.
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.pickByLimit(2, iterator)
.then(object => {
console.log(object); // { '0': 1, '1': 5, '2': 3 }
console.log(order); // [1, 3, 5, 2, 4]
});
const order = [];
const collection = { a: 1, b: 5, c: 3, d: 4, e: 2 };
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.pickByLimit(2, iterator)
.then(object => {
console.log(object); // { a: 1, b: 5, c: 3 }
console.log(order); // [1, 3, 5, 2, 4]
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.pickByLimit(iterator)
.then(object => {
console.log(object); // { '0': 1, '1': 5, '2': 3 }
console.log(order); // [1, 2, 3, 4, 5]
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
pickBySeries(iterator) → {Aigle}
Aigle#pickBySeries
is almost the same as Aigle#pickBy
, but it will work in series.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.pickBySeries(iterator)
.then(object => {
console.log(object); // { '0': 1 }
console.log(order); // [1, 4, 2]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num * 2;
});
};
Aigle.resolve(collection)
.pickBySeries(iterator)
.then(object => {
console.log(object); // { a: 1 }
console.log(order); // [1, 4, 2]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
props() → {Aigle}
Aigle#props
will execute Aigle.props
using a previous promise value.
The value will be assigned as the first argument to Aigle.props
.
Example
const order = [];
const makeDelay = (num, delay) => {
return Aigle.delay(delay)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve({
a: makeDelay(1, 30),
b: makeDelay(2, 20),
c: makeDelay(3, 10)
})
.props()
.then(object => {
console.log(object); // { a: 1, b: 2, c: 3 }
console.log(order); // [3, 2, 1]
});
Returns:
Returns an Aigle instance
- Type
- Aigle
race() → {Aigle}
Example
Aigle.resolve([
new Aigle(resolve => setTimeout(() => resolve(1), 30)),
new Aigle(resolve => setTimeout(() => resolve(2), 20)),
new Aigle(resolve => setTimeout(() => resolve(3), 10))
])
.race()
.then(value => console.log(value)); // 3
Returns:
Returns an Aigle instance
- Type
- Aigle
reason() → {*}
Returns:
- Type
- *
reduce(iterator, result) → {Aigle}
Examples
const collection = [1, 4, 2];
const iterator = (result, num, index) => {
return Aigle.delay(num * 10)
.then(() => result + num);
};
return Aigle.resolve(collection)
.reduce(iterator, 1)
.then(value => console.log(value)); // 8
const collection = { a: 1, b: 4, c: 2 };
const iterator = (result, num, key) => {
return Aigle.delay(num * 10)
.then(() => result + num);
};
return Aigle.resolve(collection)
.reduce(iterator, '')
.then(value => console.log(value)); // '142'
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | |
result |
* |
Returns:
Returns an Aigle instance
- Type
- Aigle
reject(iterator) → {Aigle}
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.reject(iterator)
.then(array => {
console.log(array); // [4, 2];
console.log(order); // [1, 2, 4];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.reject(iterator)
.then(array => {
console.log(array); // [4, 2];
console.log(order); // [1, 2, 4];
});
const order = [];
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.collection(collection)
.reject('active')
.then(array => {
console.log(array); // [{ name: 'fread', active: false }]
});
const order = [];
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.collection(collection)
.reject(['name', 'bargey'])
.then(array => {
console.log(array); // [{ name: 'fread', active: false }]
});
const order = [];
const collection = [{
name: 'bargey', active: false
}, {
name: 'fread', active: true
}];
Aigle.collection(collection)
.reject({ name: 'bargey', active: false })
.then(array => {
console.log(array); // [{ name: 'fread', active: false }]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | string |
Returns:
Returns an Aigle instance
- Type
- Aigle
rejectLimit(limitopt, iterator) → {Aigle}
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.rejectLimit(2, iterator)
.then(array => {
console.log(array); // [4, 2]
console.log(order); // [1, 3, 5, 2, 4]
});
const order = [];
const collection = { a: 1, b: 5, c: 3, d: 4, e: 2 };
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.rejectLimit(2, iterator)
.then(array => {
console.log(array); // [4, 2]
console.log(order); // [1, 3, 5, 2, 4]
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.rejectLimit(iterator)
.then(array => {
console.log(array); // [4, 2]
console.log(order); // [1, 2, 3, 4, 5]
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
rejectSeries(iterator) → {Aigle}
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.rejectSeries(iterator)
.then(array => {
console.log(array); // [4, 2];
console.log(order); // [1, 4, 2];
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2;
});
};
Aigle.resolve(collection)
.rejectSeries(iterator)
.then(array => {
console.log(array); // [4, 2];
console.log(order); // [1, 4, 2];
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
series()
Aigle#series
has the same functionality as Aigle#parallel
and it works in series.
Examples
Aigle.resolve([
() => Aigle.delay(30, 1),
Aigle.delay(20, 2),
3
])
.series()
.then(array => {
console.log(array); // [1, 2, 3]
});
Aigle.resolve({
a: () => Aigle.delay(30, 1),
b: Aigle.delay(20, 2),
c: 3
})
.series()
.then(object => {
console.log(object); // { a: 1, b: 2, c: 3 }
});
some(iterator) → {Aigle}
Aigle#some
will execute Aigle.some
using a previous promise value and a defined iterator.
The value will be assigned as the first argument to Aigle.some
and
the iterator will be assigned as the second argument.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.some(iterator)
.then(bool => {
console.log(bool); // true
console.log(order); // [1, 2]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.some(iterator)
.then(bool => {
console.log(bool); // true
console.log(order); // [1, 2]
});
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return false;
});
};
Aigle.resolve(collection)
.some(iterator)
.then(bool => {
console.log(bool); // false
console.log(order); // [1, 2, 4]
});
const collection = [{
uid: 1, active: false
}, {
uid: 4, active: true
}, {
uid: 2, active: true
}];
Aigle.resolve(collection)
.some('active')
.then(value => console.log(value)); // true
const collection = [{
uid: 1, active: false
}, {
uid: 4, active: true
}, {
uid: 2, active: true
}];
Aigle.resolve(collection)
.some(['uid', 4])
.then(value => console.log(value)); // true
const collection = [{
uid: 1, active: false
}, {
uid: 4, active: true
}, {
uid: 2, active: true
}];
Aigle.resolve(collection)
.some({ uid: 4 })
.then(value => console.log(value)); // true
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | string |
Returns:
Returns an Aigle instance
- Type
- Aigle
someLimit(limitopt, iterator) → {Aigle}
Aigle#someLimit
is almost the same as Aigle#some
and Aigle#someSeries
), but it will work with concurrency.
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.someLimit(2, iterator)
.then(bool => {
console.log(bool); // true
console.log(order); // [1, 3, 5, 2]
});
const order = [];
const collection = { a: 1, b: 5, c: 3, d: 4, e: 2 };
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.someLimit(2, iterator)
.then(bool => {
console.log(bool); // true
console.log(order); // [1, 3, 5, 2]
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.someLimit(2, iterator)
.then(bool => {
console.log(bool); // true
console.log(order); // [1, 2]
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
someSeries(iterator) → {Aigle}
Aigle#someSeries
is almost the same as Aigle#some
, but it will work in series.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.someSeries(iterator)
.then(bool => {
console.log(bool); // true
console.log(order); // [1, 4]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num % 2 === 0;
});
};
Aigle.resolve(collection)
.someSeries(iterator)
.then(bool => {
console.log(bool); // true
console.log(order); // [1, 4]
});
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return false;
});
};
Aigle.resolve(collection)
.someSeries(iterator)
.then(bool => {
console.log(bool); // false
console.log(order); // [1, 4, 2]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
sortBy(iterator) → {Aigle}
Aigle#sortBy
will execute Aigle.sortBy
using a previous promise value and a defined iterator.
The value will be assigned as the first argument to Aigle.sortBy
and
the iterator will be assigned as the second argument.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.sortBy(iterator)
.then(array => {
console.log(array); // [1, 2, 4]
console.log(order); // [1, 2, 4]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.sortBy(iterator)
.then(array => {
console.log(array); // [1, 2, 4]
console.log(order); // [1, 2, 4]
});
const order = [];
const collection = [{
uid: 2, name: 'bargey', uid: 2
}, {
uid: 1, name: 'fread'
}];
Aigle.resolve(collection)
.sortBy('uid')
.then(array => {
console.log(array); // [{ uid: 1, name: 'fread' }, { uid: 2, name: 'bargey' ]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function | string |
Returns:
Returns an Aigle instance
- Type
- Aigle
sortByLimit(limitopt, iterator) → {Aigle}
Aigle#sortByLimit
is almost the same as Aigle#sortBy
and Aigle#sortBySeries
), but it will work with concurrency.
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.sortByLimit(2, iterator)
.then(array => {
console.log(array); // [1, 2, 3, 4, 5]
console.log(order); // [1, 3, 5, 2, 4]
});
const order = [];
const collection = { a: 1, b: 5, c: 3, d: 4, e: 2 };
const iterator = (num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.sortByLimit(2, iterator)
.then(array => {
console.log(array); // [1, 2, 3, 4, 5]
console.log(order); // [1, 3, 5, 2, 4]
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.sortByLimit(iterator)
.then(array => {
console.log(array); // [1, 2, 3, 4, 5]
console.log(order); // [1, 2, 3, 4, 5]
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
sortBySeries(iterator) → {Aigle}
Aigle#sortBySeries
is almost the same as Aigle#sortBy
, but it will work in series.
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.sortBySeries(iterator)
.then(array => {
console.log(array); // [1, 2, 4]
console.log(order); // [1, 4, 2]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = num => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
return num;
});
};
Aigle.resolve(collection)
.sortBySeries(iterator)
.then(array => {
console.log(array); // [1, 2, 4]
console.log(order); // [1, 4, 2]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
spread(handler) → {Aigle}
Examples
const array = [1, 2, 3];
Aigle.resolve(array)
.spread((arg1, arg2, arg3) => {
console.log(arg1, arg2, arg3); // 1, 2, 3
});
const string = '123';
Aigle.resolve(string)
.spread((arg1, arg2, arg3) => {
console.log(arg1, arg2, arg3); // 1, 2, 3
});
Parameters:
Name | Type | Description |
---|---|---|
handler |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
tap(onFulfilled) → {Aigle}
Example
Aigle.resolve([1, 4, 2])
.tap(array => array.pop())
.then(array => {
console.log(array); // [1, 4]
});
Parameters:
Name | Type | Description |
---|---|---|
onFulfilled |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
then(onFulfilled, onRejectedopt) → {Aigle}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
onFulfilled |
function | ||
onRejected |
function |
<optional> |
Returns:
Returns an Aigle instance
- Type
- Aigle
thru(onFulfilled) → {Aigle}
Example
Aigle.resolve(3)
.thru(value => ++value)
.then(value => {
console.log(value); // 4;
});
Parameters:
Name | Type | Description |
---|---|---|
onFulfilled |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
timeout(ms, messageopt)
Example
const { TimeoutError } = Aigle;
Aigle.delay(100)
.timeout(10)
.catch(TimeoutError, error => {
console.log(error); // operation timed out
});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ms |
number | ||
message |
* |
<optional> |
times(iterator) → {Aigle}
Example
const order = [];
const timer = [30, 20, 10];
const iterator = n => {
return Aigle.delay(timer[n])
.then(() => {
order.push(n);
return n;
});
};
Aigle.resolve(3)
.times(iterator)
.then(array => {
console.log(array); // [0, 1, 2]
console.log(order); // [2, 1, 0]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
timesLimit(limitopt, iterator) → {Aigle}
Examples
const order = [];
const timer = [30, 20, 10];
const iterator = n => {
return Aigle.delay(timer[n])
.then(() => {
order.push(n);
return n;
});
};
Aigle.resolve(3)
.timesLimit(2, iterator)
.then(array => {
console.log(array); // [0, 1, 2]
console.log(order); // [1, 0, 2]
});
const order = [];
const timer = [30, 20, 10];
const iterator = n => {
return Aigle.delay(timer[n])
.then(() => {
order.push(n);
return n;
});
};
Aigle.resolve(3)
.timesLimit(iterator)
.then(array => {
console.log(array); // [0, 1, 2]
console.log(order); // [2, 1, 0]
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number |
<optional> |
8
|
|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
timesSeries(iterator) → {Aigle}
Example
const order = [];
const timer = [30, 20, 10];
const iterator = n => {
return Aigle.delay(timer[n])
.then(() => {
order.push(n);
return n;
});
};
Aigle.resolve(3)
.timesSeries(iterator)
.then(array => {
console.log(array); // [0, 1, 2]
console.log(order); // [0, 1, 2]
});
Parameters:
Name | Type | Description |
---|---|---|
iterator |
function |
Returns:
Returns an Aigle instance
- Type
- Aigle
toString() → {string}
Returns:
- Type
- string
transform(iterator, accumulatoropt) → {Aigle}
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (result, num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
result[index] = num;
});
};
Aigle.resolve(collection)
.transform(iterator, {})
.then(object => {
console.log(object); // { '0': 1, '1': 4, '2': 2 }
console.log(order); // [1, 2, 4]
});
const order = [];
const collection = [1, 4, 2];
const iterator = (result, num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
result.push(num);
});
};
Aigle.resolve(collection)
.transform(iterator, {})
.then(array => {
console.log(array); // [1, 2, 4]
console.log(order); // [1, 2, 4]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (result, num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
result.push(num);
return num !== 2;
});
};
Aigle.resolve(collection)
.transform(iterator, [])
.then(array => {
console.log(array); // [1, 2]
console.log(order); // [1, 2]
});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
iterator |
function | ||
accumulator |
Array | Object |
<optional> |
Returns:
Returns an Aigle instance
- Type
- Aigle
transformLimit(limitopt, iterator, accumulatoropt)
Examples
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (result, num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
result[index] = num;
});
};
Aigle.resolve(collection)
.transformLimit(2, iterator, {})
.then(object => {
console.log(object); // { '0': 1, '1': 5, '2': 3, '3': 4, '4': 2 }
console.log(order); // [1, 5, 3, 4, 2]
});
const order = [];
const collection = [1, 5, 3, 4, 2];
const iterator = (result, num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
result.push(num);
});
};
Aigle.resolve(collection)
.transformLimit(2, iterator, {})
.then(array => {
console.log(array); // [1, 5, 3, 4, 2]
console.log(order); // [1, 5, 3, 4, 2]
});
const order = [];
const collection = { a: 1, b: 5, c: 3, d: 4, e: 2 };
const iterator = (result, num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
result.push(num);
return num !== 4;
});
};
Aigle.resolve(collection)
.transformLimit(2, iterator, [])
.then(array => {
console.log(array); // [1, 5, 3, 4]
console.log(order); // [1, 5, 3, 4]
});
const order = [];
const collection = { a: 1, b: 5, c: 3, d: 4, e: 2 };
const iterator = (result, num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
result.push(num);
return num !== 4;
});
};
Aigle.resolve(collection)
.transformLimit(iterator, [])
.then(array => {
console.log(array); // [1, 2, 3, 4]
console.log(order); // [1, 2, 3, 4]
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
number |
<optional> |
8
|
|
iterator |
function | |||
accumulator |
Array | Object |
<optional> |
transformSeries(iterator, accumulatoropt) → {Aigle}
Examples
const order = [];
const collection = [1, 4, 2];
const iterator = (result, num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
result[index] = num;
});
};
Aigle.resolve(collection)
.transformSeries(iterator, {})
.then(object => {
console.log(object); // { '0': 1, '1': 4, '2': 2 }
console.log(order); // [1, 4, 2]
});
const order = [];
const collection = [1, 4, 2];
const iterator = (result, num, index) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
result.push(num);
});
};
Aigle.resolve(collection)
.transformSeries(iterator, {})
.then(array => {
console.log(array); // [1, 4, 2]
console.log(order); // [1, 4, 2]
});
const order = [];
const collection = { a: 1, b: 4, c: 2 };
const iterator = (result, num, key) => {
return Aigle.delay(num * 10)
.then(() => {
order.push(num);
result.push(num);
return num !== 4;
});
};
Aigle.resolve(collection)
.transformSeries(iterator, [])
.then(array => {
console.log(array); // [1, 4]
console.log(order); // [1, 4]
});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
iterator |
function | ||
accumulator |
Array | Object |
<optional> |
Returns:
Returns an Aigle instance
- Type
- Aigle
until(tester, iterator)
Parameters:
Name | Type | Description |
---|---|---|
tester |
function | |
iterator |
function |
value() → {*}
Returns:
- Type
- *
whilst(tester, iterator)
Parameters:
Name | Type | Description |
---|---|---|
tester |
function | |
iterator |
function |