mirror of
https://gitlab.silvrtree.co.uk/martind2000/md-utils.git
synced 2025-01-25 16:26:18 +00:00
added newObjectFrom
This commit is contained in:
parent
ba475dc668
commit
03ba3f83dc
34
index.js
34
index.js
@ -9,18 +9,25 @@
|
||||
|
||||
|
||||
module.exports = {
|
||||
reDashObject(source) {
|
||||
var rObj = {};
|
||||
for (var item in source) {
|
||||
if (source.hasOwnProperty(item)) {
|
||||
let newName = item.replace('_', '-');
|
||||
rObj[newName] = source[item];
|
||||
}
|
||||
newObjectFrom(source, fields) {
|
||||
var rObj = {};
|
||||
for (var item in fields) {
|
||||
if (source.hasOwnProperty(fields[item])) {
|
||||
rObj[fields[item]] = source[fields[item]];
|
||||
}
|
||||
}
|
||||
return rObj;
|
||||
}, reDashObject(source) {
|
||||
var rObj = {};
|
||||
for (var item in source) {
|
||||
if (source.hasOwnProperty(item)) {
|
||||
let newName = item.replace('_', '-');
|
||||
rObj[newName] = source[item];
|
||||
}
|
||||
}
|
||||
|
||||
return rObj;
|
||||
},
|
||||
unDashObject(source) {
|
||||
return rObj;
|
||||
}, unDashObject(source) {
|
||||
var rObj = {};
|
||||
for (var item in source) {
|
||||
if (source.hasOwnProperty(item)) {
|
||||
@ -55,8 +62,8 @@ module.exports = {
|
||||
var SCRIPT_REGEX = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
|
||||
|
||||
var CHECKCHARS = "0123456789" + // Numeric
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
|
||||
"abcdefghijklmnopqrstuvwxyz-'" + (_loose === false ? '' : "_,.!~*()@:+/\\");
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" + // Alphabetic
|
||||
"abcdefghijklmnopqrstuvwxyz-'" + (_loose === false ? '' : "_,.!~*()@:+/\\");
|
||||
|
||||
if (typeof text === 'string') {
|
||||
while (SCRIPT_REGEX.test(text)) {
|
||||
@ -67,7 +74,8 @@ module.exports = {
|
||||
ch = text.charAt(i);
|
||||
if (ch === ' ') {
|
||||
s.push(' ');
|
||||
} else if (ch.charCodeAt(0) < 255 && CHECKCHARS.indexOf(ch) !== -1) {
|
||||
}
|
||||
else if (ch.charCodeAt(0) < 255 && CHECKCHARS.indexOf(ch) !== -1) {
|
||||
s.push(ch);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user