elm-review
Advanced tools
Comparing version 2.9.0 to 2.9.1
@@ -432,3 +432,3 @@ const util = require('util'); | ||
} else { | ||
const json = JSON.stringify(context); | ||
const json = JSON.stringify(context, global.elmJsonReplacer); | ||
stringifyMap.set(context, json); | ||
@@ -435,0 +435,0 @@ return json; |
@@ -7,2 +7,30 @@ module.exports = { | ||
function replacer(key, value) { | ||
if (typeof value === 'object') { | ||
// TODO Serialize Dicts also | ||
// if (value.$ === -1) { | ||
// return { | ||
// $: '$D', | ||
// a: toDictProd(value, {}) | ||
// }; | ||
// } | ||
if ( | ||
value.$ === 1 && | ||
value.a !== undefined && | ||
value.b !== undefined && | ||
value.c === undefined | ||
) { | ||
const list = prudent_List_toArray(value); | ||
if (list === null) { | ||
return value; | ||
} | ||
return { | ||
$: '$L', | ||
a: list | ||
}; | ||
} | ||
return value; | ||
} | ||
if (Number.isNaN(value)) { | ||
@@ -23,5 +51,28 @@ return '$$elm-review$$NaN'; | ||
function prudent_List_toArray(xs) { | ||
const out = []; | ||
for (; xs.b; xs = xs.b) { | ||
if (xs.a === undefined || xs.c !== undefined) { | ||
return null; | ||
} | ||
out.push(xs.a); | ||
} | ||
if (xs.$ !== 0 || xs.a !== undefined) { | ||
return null; | ||
} | ||
return out; | ||
} | ||
function reviver(_, value) { | ||
const type_ = typeof value; | ||
if (type_ === 'object' && value.$ === '$L') { | ||
return _List_fromArray_PROD(value.a); | ||
} | ||
if ( | ||
typeof value !== 'string' || | ||
type_ !== 'string' || | ||
value === null || | ||
@@ -44,1 +95,11 @@ !value.startsWith('$$elm-review$$') | ||
} | ||
const _List_Nil_PROD = {$: 0}; | ||
function _List_fromArray_PROD(array) { | ||
let out = _List_Nil_PROD; | ||
for (let i = array.length; i--; ) { | ||
out = {$: 1, a: array[i], b: out}; | ||
} | ||
return out; | ||
} |
@@ -55,2 +55,3 @@ const path = require('path'); | ||
options.resultCacheFolder || options.resultCachePath(appHash); | ||
global.elmJsonReplacer = ResultCacheJson.replacer; | ||
@@ -57,0 +58,0 @@ global.loadResultFromCache = (ruleName, ruleId) => { |
{ | ||
"name": "elm-review", | ||
"version": "2.9.0", | ||
"version": "2.9.1", | ||
"description": "Run elm-review from Node.js", | ||
@@ -5,0 +5,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
411698
6324