camel-dot-prop-immutable
Advanced tools
Comparing version 1.3.2 to 1.4.0
@@ -31,3 +31,12 @@ "use strict"; | ||
function camelCombos(prop) { | ||
let regexes = [/\.\w/, /\.[^.]+$/]; | ||
if (Array.isArray(prop)) { | ||
prop = prop.map(p => p.replace(".", "\\.")); | ||
prop = prop.join("."); | ||
} | ||
return camelStringCombos(prop); | ||
} | ||
function camelStringCombos(prop) { | ||
let regexes = [/[^\\]\.\w/, /[^\\]\.[^.]+$/]; | ||
let combos = { [prop]: null }; | ||
@@ -40,3 +49,3 @@ let ogProp = prop; | ||
do { | ||
prop = prop.replace(regex, match => match.charAt(1).toUpperCase() + match.slice(2)); | ||
prop = prop.replace(regex, match => match.charAt(0) + match.charAt(2).toUpperCase() + match.slice(3)); | ||
combos[prop] = null; | ||
@@ -43,0 +52,0 @@ } while (prop.match(regex)); |
@@ -19,3 +19,12 @@ import dot from "dot-prop-immutable" | ||
function camelCombos(prop) { | ||
let regexes = [/\.\w/, /\.[^.]+$/] | ||
if (Array.isArray(prop)) { | ||
prop = prop.map(p => p.replace(".", "\\.")) | ||
prop = prop.join(".") | ||
} | ||
return camelStringCombos(prop) | ||
} | ||
function camelStringCombos(prop) { | ||
let regexes = [/[^\\]\.\w/, /[^\\]\.[^.]+$/] | ||
let combos = { [prop]: null } | ||
@@ -31,3 +40,5 @@ let ogProp = prop | ||
match => | ||
match.charAt(1).toUpperCase() + match.slice(2) | ||
match.charAt(0) + | ||
match.charAt(2).toUpperCase() + | ||
match.slice(3) | ||
) | ||
@@ -34,0 +45,0 @@ combos[prop] = null |
{ | ||
"name": "camel-dot-prop-immutable", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": | ||
@@ -5,0 +5,0 @@ "dot-prop-immutable w/ check for flattened props", |
@@ -22,2 +22,10 @@ import dot from "../dist" | ||
).toBe("unicorn") | ||
expect( | ||
dot.get({ foo: { barBuzz: "unicorn" } }, [ | ||
"foo", | ||
"bar", | ||
"buzz", | ||
]) | ||
).toBe("unicorn") | ||
}) | ||
@@ -43,2 +51,12 @@ | ||
}) | ||
expect( | ||
dot.set( | ||
{ "foo.fuu": { barBuzz: "a" } }, | ||
["foo.fuu", "bar", "buzz"], | ||
"b" | ||
) | ||
).toEqual({ | ||
"foo.fuu": { barBuzz: "b" }, | ||
}) | ||
}) | ||
@@ -45,0 +63,0 @@ |
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
9930
231