augmentative-iterable
Advanced tools
Comparing version 1.5.5 to 1.5.6
## 1.5.5 | ||
## 1.5.6 | ||
* cf9ffa3 fix: more micro optmizations | ||
## v1.5.5 | ||
* 8be84ac 1.5.5 | ||
* 90ecbd9 fix: micro performance and memory improvements | ||
@@ -4,0 +7,0 @@ ## v1.5.4 |
@@ -53,19 +53,15 @@ 'use strict'; | ||
function syncToAsyncFactory(asyncNext) { | ||
async function asyncProcResolving(wrapper, resolving) { | ||
if (isPromiseLike(resolving)) await resolving; | ||
switch (wrapper.state) { | ||
case YIELD: | ||
return { | ||
done: false, | ||
value: wrapper.result, | ||
}; | ||
case STOP: | ||
return end; | ||
default: | ||
return asyncNext(); | ||
}; | ||
} | ||
return asyncProcResolving; | ||
async function asyncProcResolving(wrapper, resolving, asyncNext) { | ||
if (isPromiseLike(resolving)) await resolving; | ||
switch (wrapper.state) { | ||
case YIELD: | ||
return { | ||
done: false, | ||
value: wrapper.result, | ||
}; | ||
case STOP: | ||
return end; | ||
default: | ||
return asyncNext(); | ||
}; | ||
} | ||
@@ -100,4 +96,2 @@ | ||
const asyncProcResolving = syncToAsyncFactory(asyncNext); | ||
function syncNext() { | ||
@@ -110,3 +104,3 @@ let keepGoing; | ||
const resolving = resolveState(augmentList, wrapper); | ||
if (isPromiseLike(resolving)) return asyncProcResolving(wrapper, resolving); | ||
if (isPromiseLike(resolving)) return asyncProcResolving(wrapper, resolving, asyncNext); | ||
switch (wrapper.state) { | ||
@@ -164,4 +158,2 @@ case YIELD: | ||
const asyncProcResolving = syncToAsyncFactory(asyncNext); | ||
async function asyncProcNext(next) { | ||
@@ -176,3 +168,3 @@ next = await next; | ||
const resolving = resolveState(augmentList, wrapper); | ||
return asyncProcResolving(wrapper, resolving); | ||
return asyncProcResolving(wrapper, resolving, asyncNext); | ||
} | ||
@@ -192,3 +184,3 @@ | ||
const resolving = resolveState(augmentList, wrapper); | ||
if (isPromiseLike(resolving)) return asyncProcResolving(wrapper, resolving); | ||
if (isPromiseLike(resolving)) return asyncProcResolving(wrapper, resolving, asyncNext); | ||
switch (wrapper.state) { | ||
@@ -195,0 +187,0 @@ case YIELD: |
@@ -138,3 +138,3 @@ 'use strict'; | ||
const flatMapIterable = function* flatMapAsyncIterable(iterable, mapper) { | ||
const flatMapIterable = function* flatMapIterable(iterable, mapper) { | ||
if (mapper) { | ||
@@ -141,0 +141,0 @@ for (const item of iterable) { |
@@ -13,12 +13,8 @@ 'use strict'; | ||
}; | ||
function isPromiseLike(p) { | ||
return p && typeof p.then === 'function'; | ||
} | ||
const isPromiseLike = (p) => p && typeof p.then === 'function'; | ||
function resolverAsync( | ||
const resolverAsync = ( | ||
promise, | ||
callback, | ||
) { | ||
return isPromiseLike(promise) ? promise.then(callback) : callback(promise); | ||
} | ||
) => isPromiseLike(promise) ? promise.then(callback) : callback(promise); | ||
@@ -54,47 +50,41 @@ function processActionResult( | ||
function getSkippedAugmentIterable( | ||
const getSkippedAugmentIterable = ( | ||
iteratorType, | ||
augmentativeIterate, | ||
) { | ||
return function (it, offset = 0) { | ||
const augmentList = it[augments]; | ||
let baseOffset; | ||
) => function (it, offset = 0) { | ||
const augmentList = it[augments]; | ||
let baseOffset; | ||
if (!augmentList || !augmentList.last) baseOffset = it[offsetSymbol]; | ||
if (!augmentList || !augmentList.last) baseOffset = it[offsetSymbol]; | ||
return { | ||
[iteratorType]: augmentativeIterate, | ||
[baseIterable]: it, | ||
[offsetSymbol]: (baseOffset || 0) + Math.max(offset, 0), | ||
}; | ||
return { | ||
[iteratorType]: augmentativeIterate, | ||
[baseIterable]: it, | ||
[offsetSymbol]: (baseOffset || 0) + Math.max(offset, 0), | ||
}; | ||
} | ||
}; | ||
function getAugmentIterable( | ||
const getAugmentIterable = ( | ||
iteratorType, | ||
augmentativeIterate, | ||
type, | ||
) { | ||
return function (it, action,) { | ||
const augmentList = it[augments]; | ||
const augment = { | ||
type, | ||
action, | ||
}; | ||
if (augmentList && it[iteratorType]) { | ||
augmentList.last = augmentList.last.next = augment; | ||
return it; | ||
} | ||
) => function (it, action,) { | ||
const augmentList = it[augments]; | ||
const augment = { | ||
type, | ||
action, | ||
}; | ||
if (augmentList && it[iteratorType]) { | ||
augmentList.last = augmentList.last.next = augment; | ||
return it; | ||
} | ||
return { | ||
[iteratorType]: augmentativeIterate, | ||
[augments]: { next: augment, last: augment }, | ||
[baseIterable]: it, | ||
}; | ||
return { | ||
[iteratorType]: augmentativeIterate, | ||
[augments]: { next: augment, last: augment }, | ||
[baseIterable]: it, | ||
}; | ||
} | ||
}; | ||
function resolver(value, callback) { | ||
return callback(value); | ||
} | ||
const resolver = (value, callback) => callback(value); | ||
@@ -101,0 +91,0 @@ function getIterableParameters(self, next, iteratorSymbol, augmentativeIterate) { |
{ | ||
"name": "augmentative-iterable", | ||
"description": "This project is just a template for creation of new projects", | ||
"version": "1.5.5", | ||
"version": "1.5.6", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "author": { |
38430
830