Skip to content

Commit 7bb4f83

Browse files
committed
Rename to YieldStructure to avoid certain overzealous transpilers
1 parent f4ff4bc commit 7bb4f83

File tree

13 files changed

+47
-47
lines changed

13 files changed

+47
-47
lines changed

async.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AsyncLogicEngine } from './index.js'
2-
import Yield from './structures/Yield.js'
2+
import YieldStructure from './structures/Yield.js'
33
import EngineObject from './structures/EngineObject.js'
44

55
const modes = [
@@ -780,7 +780,7 @@ modes.forEach((logic) => {
780780

781781
if (engine.allowFunctions || typeof context[key] !== 'function') {
782782
if (!(key in context)) {
783-
return new Yield({
783+
return new YieldStructure({
784784
message: 'Data does not exist in context.'
785785
})
786786
}

asyncLogic.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import checkYield from './utilities/checkYield.js'
55
import defaultMethods from './defaultMethods.js'
6-
import Yield from './structures/Yield.js'
6+
import YieldStructure from './structures/Yield.js'
77
import EngineObject from './structures/EngineObject.js'
88
import LogicEngine from './logic.js'
99
import asyncPool from './asyncPool.js'
@@ -152,7 +152,7 @@ class AsyncLogicEngine {
152152
const result = await this._parse(func, logic[func], data, above)
153153

154154
if (this.options.yieldSupported && (await checkYield(result))) {
155-
if (result instanceof Yield) {
155+
if (result instanceof YieldStructure) {
156156
if (result._input) {
157157
result._logic = { [func]: result._input }
158158
}

compiler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
// Override is required for the compiler to operate as intended.
77
Override
88
} from './constants.js'
9-
import Yield from './structures/Yield.js'
9+
import YieldStructure from './structures/Yield.js'
1010
import declareSync from './utilities/declareSync.js'
1111

1212
// asyncIterators is required for the compiler to operate as intended.
@@ -115,7 +115,7 @@ function r (func, input, name, resumable) {
115115
? func(resumable[name + '_input'])
116116
: func(typeof input === 'function' ? input() : input)
117117

118-
if (result instanceof Yield) {
118+
if (result instanceof YieldStructure) {
119119
if (result._input) {
120120
resumable[name + '_input'] = result._input
121121
}
@@ -145,7 +145,7 @@ async function rAsync (func, input, name, resumable) {
145145
? await func(resumable[name + '_input'])
146146
: await func(typeof input === 'function' ? await input() : input)
147147

148-
if (result instanceof Yield) {
148+
if (result instanceof YieldStructure) {
149149
if (result._input) {
150150
resumable[name + '_input'] = result._input
151151
}

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import LogicEngine from './logic.js'
55
import AsyncLogicEngine from './asyncLogic.js'
66
import Compiler from './compiler.js'
7-
import Yield from './structures/Yield.js'
7+
import YieldStructure from './structures/Yield.js'
88
import EngineObject from './structures/EngineObject.js'
99
import Constants from './constants.js'
1010
import defaultMethods from './defaultMethods.js'
@@ -13,11 +13,11 @@ import { asLogicSync, asLogicAsync } from './asLogic.js'
1313
export { LogicEngine }
1414
export { AsyncLogicEngine }
1515
export { Compiler }
16-
export { Yield }
16+
export { YieldStructure }
1717
export { EngineObject }
1818
export { Constants }
1919
export { defaultMethods }
2020
export { asLogicSync }
2121
export { asLogicAsync }
2222

23-
export default { LogicEngine, AsyncLogicEngine, Compiler, Yield, EngineObject, Constants, defaultMethods, asLogicSync, asLogicAsync }
23+
export default { LogicEngine, AsyncLogicEngine, Compiler, YieldStructure, EngineObject, Constants, defaultMethods, asLogicSync, asLogicAsync }

logic.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import checkYield from './utilities/checkYield.js'
55
import defaultMethods from './defaultMethods.js'
6-
import Yield from './structures/Yield.js'
6+
import YieldStructure from './structures/Yield.js'
77
import EngineObject from './structures/EngineObject.js'
88
import { build } from './compiler.js'
99
import declareSync from './utilities/declareSync.js'
@@ -114,7 +114,7 @@ class LogicEngine {
114114
const [func] = Object.keys(logic)
115115
const result = this._parse(func, logic[func], data, above)
116116
if (this.options.yieldSupported && checkYield(result)) {
117-
if (result instanceof Yield) {
117+
if (result instanceof YieldStructure) {
118118
if (result._input) {
119119
result._logic = { [func]: result._input }
120120
}

package.json

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

structures/EngineObject.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
'use strict'
33

44
import traverseCopy from '../utilities/traverseCopy.js'
5-
import Yield from './Yield.js'
5+
import YieldStructure from './Yield.js'
66

77
function fetchYields (obj, arr = []) {
8-
if (obj instanceof Yield) {
8+
if (obj instanceof YieldStructure) {
99
arr.push(obj)
1010
return arr
1111
}
@@ -33,12 +33,12 @@ class EngineObject {
3333
{},
3434
{
3535
mutateValue: (i) => {
36-
if (i instanceof Yield) {
36+
if (i instanceof YieldStructure) {
3737
return i.logic()
3838
}
3939
return i
4040
},
41-
skipCopy: (i) => i instanceof Yield
41+
skipCopy: (i) => i instanceof YieldStructure
4242
}
4343
)
4444
}

structures/ReduceIterator.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22
'use strict'
33

4-
import Yield from './Yield.js'
4+
import YieldStructure from './Yield.js'
55
import EngineObject from './EngineObject.js'
66

77
// works fine for arrays, may need to create a more general version though
@@ -19,7 +19,7 @@ class ReduceIterator {
1919
const item = this.arr[this.position]
2020
this._position = this.position
2121
const cur = this.nextCall(this.cur, item, this.arr, this)
22-
if (cur instanceof Yield || cur instanceof EngineObject) {
22+
if (cur instanceof YieldStructure || cur instanceof EngineObject) {
2323
return cur
2424
}
2525
// commit
@@ -54,7 +54,7 @@ class AsyncReduceIterator extends ReduceIterator {
5454
const item = this.arr[this.position]
5555
this._position = this.position
5656
const cur = await this.nextCall(this.cur, item, this.arr, this)
57-
if (cur instanceof Yield || cur instanceof EngineObject) {
57+
if (cur instanceof YieldStructure || cur instanceof EngineObject) {
5858
return cur
5959
}
6060
// commit

structures/Yield.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* A class that handles the Yielding logic & helps generate replacement logic.
55
*/
6-
class Yield {
6+
class YieldStructure {
77
constructor (data) {
88
this._logic = null
99
this.resumable = null
@@ -18,4 +18,4 @@ class Yield {
1818
return this._logic
1919
}
2020
}
21-
export default Yield
21+
export default YieldStructure

test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LogicEngine } from './index.js'
2-
import Yield from './structures/Yield.js'
2+
import YieldStructure from './structures/Yield.js'
33
import EngineObject from './structures/EngineObject.js'
44

55
const modes = [
@@ -856,7 +856,7 @@ modes.forEach((logic) => {
856856
}
857857
if (engine.allowFunctions || typeof context[key] !== 'function') {
858858
if (!(key in context)) {
859-
return new Yield({
859+
return new YieldStructure({
860860
message: 'Data does not exist in context.'
861861
})
862862
}

0 commit comments

Comments
 (0)