Skip to content

Commit eb3b313

Browse files
committed
Remove code that hasn't been necessary for years, since we got rid of the Proxy mechanism that assigns a value. Also add additional condition
1 parent dd6902e commit eb3b313

File tree

4 files changed

+14
-64
lines changed

4 files changed

+14
-64
lines changed

async.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -860,5 +860,12 @@ modes.forEach((logic) => {
860860
await logic.run([{ test: true }, { test: true }])
861861
).toStrictEqual(['1337', '1337'])
862862
})
863+
864+
test('async + non-determistic function inside array', async () => {
865+
logic.addMethod('test', async () => '1337')
866+
expect(
867+
await logic.run([{ test: true }, { test: true }])
868+
).toStrictEqual(['1337', '1337'])
869+
})
863870
})
864871
})

asyncLogic.js

+6-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import defaultMethods from './defaultMethods.js'
55
import LogicEngine from './logic.js'
6-
import asyncPool from './asyncPool.js'
76
import { isSync } from './constants.js'
87
import declareSync from './utilities/declareSync.js'
98
import { buildAsync } from './compiler.js'
@@ -204,11 +203,11 @@ class AsyncLogicEngine {
204203
/**
205204
*
206205
* @param {*} logic The logic to be built.
207-
* @param {{ top?: Boolean, above?: any, max?: Number }} options
206+
* @param {{ top?: Boolean, above?: any }} options
208207
* @returns {Promise<Function>}
209208
*/
210209
async build (logic, options = {}) {
211-
const { above = [], max = 100, top = true } = options
210+
const { above = [], top = true } = options
212211
this.fallback.truthy = this.truthy
213212
if (top) {
214213
const constructedFunction = await buildAsync(logic, {
@@ -238,21 +237,10 @@ class AsyncLogicEngine {
238237

239238
return result
240239
}, top !== true && isSync(constructedFunction))
241-
// we can avoid the async pool if the constructed function is synchronous since the data
242-
// can't be updated :)
243-
if (top === true && constructedFunction && !isSync(constructedFunction) && typeof constructedFunction === 'function') {
244-
// we use this async pool so that we can execute these in parallel without having
245-
// concerns about the data.
246-
return asyncPool({
247-
free: [result],
248-
max,
249-
create: () => this.build(logic, { ...options, above })
250-
})
251-
} else {
252-
return typeof constructedFunction === 'function' || top === true
253-
? result
254-
: constructedFunction
255-
}
240+
241+
return typeof constructedFunction === 'function' || top === true
242+
? result
243+
: constructedFunction
256244
}
257245

258246
return logic

asyncPool.js

-45
This file was deleted.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-logic-engine",
3-
"version": "2.1.3",
3+
"version": "2.1.4",
44
"description": "Construct complex rules with JSON & process them.",
55
"main": "./dist/cjs/index.js",
66
"module": "./dist/esm/index.js",

0 commit comments

Comments
 (0)