@philippfromme/moddle-helpers
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -9,2 +9,6 @@ # Changelog | ||
## 0.4.0 | ||
* `FEAT`: handle `null` and `undefined` paths ([`49651c`](https://github.com/philippfromme/moddle-helpers/commit/49651c16b359829e3639f10da683dc665e11f886)) | ||
## 0.3.0 | ||
@@ -11,0 +15,0 @@ |
17
index.js
const { | ||
isNil, | ||
isString | ||
isString, | ||
isUndefined | ||
} = require('min-dash'); | ||
@@ -82,3 +83,3 @@ | ||
for (let path of paths) { | ||
if (isNil(path)) { | ||
if (isNil(path) || isUndefined(path)) { | ||
return null; | ||
@@ -105,2 +106,6 @@ } | ||
module.exports.pathEquals = function(a, b, separator = '.') { | ||
if (isNil(a) || isUndefined(a) || isNil(b) || isUndefined(b)) { | ||
return false; | ||
} | ||
if (!isString(a)) { | ||
@@ -124,2 +129,6 @@ a = pathStringify(a, separator); | ||
module.exports.pathParse = function(path, separator = '.') { | ||
if (isNil(path) || isUndefined(path)) { | ||
return null; | ||
} | ||
return path | ||
@@ -137,2 +146,6 @@ .split(separator) | ||
function pathStringify(path, separator = '.') { | ||
if (isNil(path) || isUndefined(path)) { | ||
return null; | ||
} | ||
return path.join(separator); | ||
@@ -139,0 +152,0 @@ } |
{ | ||
"name": "@philippfromme/moddle-helpers", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -18,8 +18,9 @@ # moddle-helpers | ||
// null | ||
const task = moddle.create('bpmn:Task'); // task.$parent === undefined | ||
// $parent === undefined | ||
const task = moddle.create('bpmn:Task'); | ||
getPath(task); // null | ||
getPath(undefined); // null | ||
// null | ||
getPath(null); // null | ||
``` | ||
@@ -34,2 +35,3 @@ | ||
// null | ||
pathConcat([ 'foo', 'bar' ], null); // null | ||
@@ -49,3 +51,6 @@ ``` | ||
// custom separator | ||
parsePath('extensionElements-values-0-type', 'extensionElements-values-0-type', '-'); // true | ||
pathEquals('extensionElements-values-0-type', 'extensionElements-values-0-type', '-'); // true | ||
// null | ||
pathEquals(null, [ 'foo' ]); // false | ||
``` | ||
@@ -63,2 +68,5 @@ | ||
parsePath('rootElements-0-flowElements-0-extensionElements-values-0-type', '-'); // [ 'rootElements', 0, 'flowElements', 0, 'extensionElements', 'values', 0 ] | ||
// null | ||
parsePath(null); // null | ||
``` | ||
@@ -76,2 +84,5 @@ | ||
stringifyPath([ 'rootElements', 0, 'flowElements', 0, 'extensionElements', 'values', 0 ], '-'); // 'rootElements-0-flowElements-0-extensionElements-values-0-type' | ||
// null | ||
stringifyPath(null); // null | ||
``` | ||
@@ -78,0 +89,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
6957
125
87