Comparing version 0.0.11 to 0.0.12
# code-red changelog | ||
## 0.0.12 | ||
* Flatten object properties | ||
## 0.0.11 | ||
@@ -4,0 +8,0 @@ |
@@ -184,2 +184,19 @@ (function (global, factory) { | ||
const flatten_properties = (array, target) => { | ||
for (let i = 0; i < array.length; i += 1) { | ||
const property = array[i]; | ||
if (!property.value) continue; | ||
if (property.key === property.value && Array.isArray(property.key)) { | ||
flatten_properties(property.key, target); | ||
continue; | ||
} | ||
target.push(property); | ||
} | ||
return target; | ||
}; | ||
const flatten = (nodes, target) => { | ||
@@ -208,2 +225,4 @@ for (let i = 0; i < nodes.length; i += 1) { | ||
if (node.type === 'Property' && Array.isArray(node.key)) ; | ||
if (node.type === 'Identifier') { | ||
@@ -224,2 +243,6 @@ re.lastIndex = 0; | ||
if (value && value.type === 'Identifier' && value.name.startsWith(`letters =`)) { | ||
throw new Error(`wut ${match[1]}`); | ||
} | ||
if (index === null) { | ||
@@ -254,3 +277,3 @@ (parent )[key] = value; | ||
if (node.type === 'ObjectExpression') { | ||
node.properties = node.properties.filter((prop) => prop.value); | ||
node.properties = flatten_properties(node.properties, []); | ||
} | ||
@@ -332,4 +355,8 @@ | ||
str = str.replace(re, (m, i, s, n) => { | ||
if (s) return sigils[s] + n; | ||
re.lastIndex = 0; | ||
str = str.replace(re, (m, i, at, hash, name) => { | ||
if (at) return `@${name}`; | ||
if (hash) return `#${name}`; | ||
return '${...}'; | ||
@@ -336,0 +363,0 @@ }); |
{ | ||
"name": "code-red", | ||
"description": "code-red", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"repository": "Rich-Harris/code-red", | ||
@@ -6,0 +6,0 @@ "main": "dist/code-red.js", |
Sorry, the diff of this file is not supported yet
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
22300
593