Skip to content

Commit

Permalink
Retry fixing node 8.
Browse files Browse the repository at this point in the history
  • Loading branch information
EmileSonneveld committed Jul 4, 2022
1 parent 3c194de commit 94e20bf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ node_js:
- 8
- 10
- 12
- node # latest version
- 16
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ This gives the following string as result:

You can parse this results with `eval(str)` to get back a real JS object.

Take a look to [the tests](test/index.test.js.md) for more examples.
Take a look to [the tests](test/index.test.js) for more examples.

**Parameters**

Expand Down
16 changes: 8 additions & 8 deletions src/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Ref = require('./internal/reference')
const {slog} = require('./index')

/**
* Figuratly search a needle in the haystack.
* Figuratively search a needle in the haystack.
* Breath first traversal to have the smallest possible paths:
* https://en.wikipedia.org/wiki/Breadth-first_search#Pseudocode
* @param {*} needle
Expand All @@ -21,7 +21,7 @@ function search(needle, opts = null) {
const results = [];

const visitedRefs = new Map()
visitedRefs.set(opts.root, {parent: null, acces: 'globalThis'})
visitedRefs.set(opts.root, {parent: null, access: 'globalThis'})
const queue = []
queue.push(opts.root)

Expand All @@ -45,12 +45,12 @@ function search(needle, opts = null) {
if (propDesc.get && !(utils.isSimpleGetter(propDesc.get) || (propDesc.get + '').indexOf(' [native code] ') !== -1)) {
continue
}
let acces = Ref.isSafeKey(key) ? `.${key}` : `[${utils.quote(key, opts)}]`;
let access = Ref.isSafeKey(key) ? `.${key}` : `[${utils.quote(key, opts)}]`;
let child = source[key]
if (typeof child == "function" && utils.isSimpleGetter(child)) {
visitedRefs.set(child, {parent: source, acces})
visitedRefs.set(child, {parent: source, access})
// jump inside the function
acces = "()";
access = "()";
source = child;
child = child();
}
Expand All @@ -72,9 +72,9 @@ function search(needle, opts = null) {
)
) {
let el = visitedRefs.get(source)
let breadcrumbs = acces;
let breadcrumbs = access;
while (true) {
breadcrumbs = el.acces + breadcrumbs
breadcrumbs = el.access + breadcrumbs
if (el.parent == null) {
break;
}
Expand All @@ -93,7 +93,7 @@ function search(needle, opts = null) {
if (visitedRefs.has(child)) {
// nothing to do
} else {
visitedRefs.set(child, {parent: source, acces})
visitedRefs.set(child, {parent: source, access})
queue.push(child)
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/serialize-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const s = require('../src/index').serialize
const chai = require('chai')
const expect = chai.expect

if (typeof self !== 'undefined') {
URL = require('url').URL
}

const serialize = function (src, opts = null) {
opts = {
Expand Down

0 comments on commit 94e20bf

Please sign in to comment.