cleaner-node
Advanced tools
Comparing version 0.15.0 to 0.15.1
{ | ||
"name": "cleaner-node", | ||
"version": "0.15.0", | ||
"version": "0.15.1", | ||
"description": "Helpful utilities and scripts to make Node projects more legible and easier for the next developer to take over.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -57,2 +57,3 @@ # cleaner-node | ||
| 0.14.0 | 2021/08/08 | Add `strings.trimToNull`. | | ||
| 0.15.0 | 2021/08/08 | Add `numbers.random`. | | ||
| 0.15.0 | 2021/08/23 | Add `numbers.random`. | | ||
| 0.15.1 | 2021/08/29 | Add `constants.regex`. | |
@@ -45,2 +45,6 @@ const wells = require('know-your-http-well'); | ||
} | ||
}, | ||
regex: { | ||
ALPHANUMERIC_DELIMITED: '^[a-zA-Z\\d-_]+$', | ||
ENUM_NAMES: '^[a-zA-Z\\d_]+$' | ||
} | ||
@@ -47,0 +51,0 @@ }; |
@@ -100,22 +100,22 @@ const { isValid: isValidString, toCamelCase } = require('./strings'); | ||
const toDto = value => { | ||
if (typeof value === 'undefined') { return value; } | ||
if (value instanceof Array) { return value; } | ||
const copy = JSON.parse(JSON.stringify(value)); | ||
const keys = Object.keys(copy).filter(isValidString); | ||
// eslint-disable-next-line no-eq-null | ||
const targets = keys.filter(k => (copy[k] == null)); | ||
if (keys.includes('id') && keys.includes('uid') && !targets.includes('id') && !targets.includes('uid')) { | ||
targets.push('id'); | ||
} | ||
targets.forEach(key => { | ||
Reflect.deleteProperty(copy, key); | ||
}); | ||
return copy; | ||
}; | ||
const toDtos = values => { | ||
return [].concat(values) | ||
.filter(v => (typeof v !== 'undefined')) | ||
.map(v => (toDto(v))); | ||
}; | ||
// const toDto = value => { | ||
// if (typeof value === 'undefined') { return value; } | ||
// if (value instanceof Array) { return value; } | ||
// const copy = JSON.parse(JSON.stringify(value)); | ||
// const keys = Object.keys(copy).filter(isValidString); | ||
// // eslint-disable-next-line no-eq-null | ||
// const targets = keys.filter(k => (copy[k] == null)); | ||
// if (keys.includes('id') && keys.includes('uid') && !targets.includes('id') && !targets.includes('uid')) { | ||
// targets.push('id'); | ||
// } | ||
// targets.forEach(key => { | ||
// Reflect.deleteProperty(copy, key); | ||
// }); | ||
// return copy; | ||
// }; | ||
// const toDtos = values => { | ||
// return [].concat(values) | ||
// .filter(v => (typeof v !== 'undefined')) | ||
// .map(v => (toDto(v))); | ||
// }; | ||
@@ -350,4 +350,4 @@ // --- getValue ... from singular property | ||
setValue, | ||
toDto, | ||
toDtos, | ||
// toDto, | ||
// toDtos, | ||
toPrintable, | ||
@@ -354,0 +354,0 @@ print, |
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
78977
1998
59