flow like the river

This commit is contained in:
root 2025-11-07 00:06:12 +01:00
commit 013fe673f3
42435 changed files with 5764238 additions and 0 deletions

View file

@ -0,0 +1,101 @@
/*
* @copyright 2015- commenthol
* @license MIT
*/
'use strict';
var utils = require('./utils');
var KEY = /^[a-zA-Z$_][a-zA-Z$_0-9]*$/;
/**
* handle references
* @constructor
* @param {Object} references
* @param {boolean} opts.unsafe
*/
function Ref(references, opts) {
this.keys = [];
this.refs = [];
this.key = [];
this.references = references || [];
this._opts = opts || {};
}
/**
* wrap an object key
* @api private
* @param {String} key - objects key
* @return {String} wrapped key in quotes if necessary
*/
Ref.wrapkey = function (key, opts) {
return KEY.test(key) ? key : utils.quote(key, opts);
};
Ref.prototype = {
/**
* push `key` to interal array
* @param {String} key
*/
push: function push(key) {
this.key.push(key);
},
/**
* remove the last key from internal array
*/
pop: function pop() {
this.key.pop();
},
/**
* join the keys
*/
join: function join(key) {
var _this = this;
var out = '';
key = key || this.key;
if (typeof key === 'string') {
key = [key];
}
key.forEach(function (k) {
if (KEY.test(k)) {
out += '.' + k;
} else {
out += '[' + Ref.wrapkey(k, _this._opts) + ']';
}
});
return out;
},
/**
* check if object `source` has an already known reference.
* If so then origin and source are stored in `opts.reference`
* @param {Object} source - object to compare
* @return {Boolean}
*/
hasReference: function hasReference(source) {
var idx;
if (~(idx = this.refs.indexOf(source))) {
this.references.push([this.join(), this.keys[idx]]);
return true;
} else {
this.refs.push(source);
this.keys.push(this.join());
}
},
/**
* get the references array
* @return {Array} references array
*/
getReferences: function getReferences() {
return this.references;
}
};
module.exports = Ref;

74
BACK_BACK/node_modules/serialize-to-js/lib/internal/utils.js generated vendored Executable file
View file

@ -0,0 +1,74 @@
'use strict';
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
var UNSAFE_CHARS_REGEXP = /[<>\u2028\u2029/\\\r\n\t"]/g;
var CHARS_REGEXP = /[\\\r\n\t"]/g;
var UNICODE_CHARS = {
'"': '\\"',
'\n': '\\n',
'\r': '\\r',
'\t': '\\t',
'\\': "\\u005C",
'<': "\\u003C",
'>': "\\u003E",
'/': "\\u002F",
"\u2028": "\\u2028",
"\u2029": "\\u2029"
};
function safeString(str) {
return str.replace(UNSAFE_CHARS_REGEXP, function (unsafeChar) {
return UNICODE_CHARS[unsafeChar];
});
}
function unsafeString(str) {
str = str.replace(CHARS_REGEXP, function (unsafeChar) {
return UNICODE_CHARS[unsafeChar];
});
return str;
}
function quote(str, opts) {
var fn = opts.unsafe ? unsafeString : safeString;
return str ? "\"".concat(fn(str), "\"") : '';
}
function saferFunctionString(str, opts) {
return opts.unsafe ? str : str.replace(/(<\/?)([a-z][^>]*?>)/ig, function (m, m1, m2) {
return safeString(m1) + m2;
});
}
function isObject(arg) {
return _typeof(arg) === 'object' && arg !== null;
}
function isBuffer(arg) {
return arg instanceof Buffer;
}
function isInvalidDate(arg) {
return isNaN(arg.getTime());
}
function toType(o) {
var _type = Object.prototype.toString.call(o);
var type = _type.substring(8, _type.length - 1);
if (type === 'Uint8Array' && isBuffer(o)) return 'Buffer';
return type;
}
module.exports = {
safeString: safeString,
unsafeString: unsafeString,
quote: quote,
saferFunctionString: saferFunctionString,
isBuffer: isBuffer,
isObject: isObject,
isInvalidDate: isInvalidDate,
toType: toType
};