jskos-tools
Advanced tools
Comparing version 0.1.22 to 0.1.23
@@ -64,4 +64,5 @@ const _ = require("lodash") | ||
* @param {array} replaceCircular - additional property names that should be replace with open world [null] statements | ||
* @param {bool} skipUnderscore - whether to skip properties starting with `_` (default `true`) | ||
*/ | ||
const copyDeep = (object, replaceCircular = []) => { | ||
const copyDeep = (object, replaceCircular = [], skipUnderscore = true) => { | ||
replaceCircular = replaceCircular.concat([ | ||
@@ -73,3 +74,3 @@ "ancestors", "narrower", "broader", "mappings", "TOPCONCEPTS", "MAPPINGS", "PROVIDER" | ||
// Ignore all properties starting with _ | ||
if (i[0] == "_") { | ||
if (skipUnderscore && i[0] == "_") { | ||
continue | ||
@@ -76,0 +77,0 @@ } |
{ | ||
"name": "jskos-tools", | ||
"version": "0.1.22", | ||
"version": "0.1.23", | ||
"description": "Tools for working with the JSKOS data format.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/gbv/jskos-tools", |
@@ -148,6 +148,8 @@ # JSKOS Tools | ||
#### copyDeep | ||
Creates a deep copy of a JSKOS object, replacing possibly circular structures with open world `[null]` statements. Ignores all properties starting with `_`. | ||
Creates a deep copy of a JSKOS object, replacing possibly circular structures with open world `[null]` statements. As the second argument it is possible to add additional properties that should be replaced with open world `[null]` statements. The third argument determines whether all properties starting with `_` should be ignored (`true` by default). | ||
```js | ||
jskos.copyDeep(object) | ||
jskos.copyDeep(object, ["someCircularProperty"]) | ||
jskos.copyDeep(object, null, false) | ||
``` | ||
@@ -154,0 +156,0 @@ |
@@ -44,2 +44,5 @@ const assert = require("assert") | ||
assert.equal(copy._test, undefined) | ||
// Test skipUnderscore | ||
let copy2 = tools.copyDeep(object, ["self"], false) | ||
assert.equal(copy2._test, object._test) | ||
}) | ||
@@ -46,0 +49,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
185192
2870
330