@jymfony/util
Advanced tools
Comparing version 0.1.0-alpha.13 to 0.1.0-alpha.14
@@ -51,3 +51,5 @@ require('./lib/Error/trigger_deprecated'); | ||
require('./lib/Async/Async'); | ||
require('./lib/Async/ClsTrait'); | ||
require('./lib/Async/ForAwait'); | ||
require('./lib/Async/Mutex'); | ||
require('./lib/Async/sleep'); |
@@ -5,4 +5,4 @@ 'use strict'; | ||
__jymfony.trigger_deprecated = function (message = '') { | ||
__jymfony.trigger_deprecated = (message = '') => { | ||
process.emitWarning(message, 'DeprecationWarning'); | ||
}; |
@@ -17,3 +17,3 @@ /** | ||
* | ||
* @returns {Function} | ||
* @returns {Function|GeneratorFunction} | ||
*/ | ||
@@ -20,0 +20,0 @@ constructor(thisArg, func) { |
@@ -6,13 +6,13 @@ 'use strict'; | ||
* | ||
* @param {*} arg | ||
* @param {*} value | ||
* | ||
* @returns {Boolean} | ||
* @returns {boolean} | ||
*/ | ||
const isCallableArray = function isCallableArray(arg) { | ||
if (! isArray(arg) || 2 !== arg.length) { | ||
global.isCallableArray = function isCallableArray(value) { | ||
if (! isArray(value) || 2 !== value.length) { | ||
return false; | ||
} | ||
const target = arg[0]; | ||
return isString(arg[1]) && isFunction(target[arg[1]]); | ||
const target = value[0]; | ||
return isString(value[1]) && isFunction(target[value[1]]); | ||
}; | ||
@@ -25,6 +25,7 @@ | ||
* | ||
* @param {Array} arg | ||
* @returns {Function|BoundFunction} | ||
* @param {[string, string]} arg | ||
* | ||
* @returns {BoundFunction} | ||
*/ | ||
const getCallableFromArray = function getCallableFromArray(arg) { | ||
global.getCallableFromArray = function getCallableFromArray(arg) { | ||
if (! isCallableArray(arg)) { | ||
@@ -39,4 +40,1 @@ throw new LogicException(arg + ' is not a callable array'); | ||
}; | ||
global.isCallableArray = isCallableArray; | ||
global.getCallableFromArray = getCallableFromArray; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
__jymfony.getFunction = function getFunction(object, funcName) { | ||
__jymfony.getFunction = (object, funcName) => { | ||
if (isFunction(object.constructor[funcName])) { | ||
@@ -8,0 +8,0 @@ return object.constructor[funcName]; |
@@ -21,4 +21,11 @@ global.isGenerator = function isGenerator(value) { | ||
if ('[object AsyncGeneratorFunction]' === Object.prototype.toString.call(value)) { | ||
return true; | ||
} | ||
if (isGeneratorFunction(value.__invoke)) { | ||
return true; | ||
} | ||
const constructor = value.constructor; | ||
if (! constructor) { | ||
@@ -65,2 +72,6 @@ return false; | ||
global.isFunction = function isFunction(obj) { | ||
if (! obj) { | ||
return false; | ||
} | ||
if (undefined !== global.BoundFunction && obj instanceof BoundFunction) { | ||
@@ -78,3 +89,7 @@ return true; | ||
if (isFunction(obj.__invoke)) { | ||
return true; | ||
} | ||
return '[object Function]' === Object.prototype.toString.call(obj); | ||
}; |
@@ -6,5 +6,5 @@ const Mixins = require('./Mixins/Mixins'); | ||
/** | ||
* @param {Function} definition | ||
* @param {*} definition | ||
* | ||
* @returns {Function} | ||
* @returns {* & MixinInterface} | ||
*/ | ||
@@ -16,5 +16,5 @@ global.getInterface = function getInterface(definition) { | ||
/** | ||
* @param {Function} definition | ||
* @param {*} definition | ||
* | ||
* @returns {Function} | ||
* @returns {* & MixinInterface} | ||
*/ | ||
@@ -86,3 +86,3 @@ global.getTrait = function getTrait(definition) { | ||
/** | ||
* @param {...} interfaces | ||
* @param {...MixinInterface} interfaces | ||
* | ||
@@ -89,0 +89,0 @@ * @returns {Object} |
@@ -10,3 +10,3 @@ 'use strict'; | ||
*/ | ||
__jymfony.clone = function clone(object) { | ||
__jymfony.clone = (object) => { | ||
if (! isObject(object)) { | ||
@@ -28,3 +28,3 @@ throw new InvalidArgumentException('Cannot clone a non-object'); | ||
/** | ||
* @param {Object} object | ||
* @param {Object} object | ||
* @returns {Object} | ||
@@ -31,0 +31,0 @@ */ |
@@ -6,7 +6,7 @@ 'use strict'; | ||
/** | ||
* @param {...} args | ||
* @param {...*} args | ||
* | ||
* @returns {Object} | ||
*/ | ||
const deepMerge = function (...args) { | ||
const deepMerge = (...args) => { | ||
if (2 === args.length) { | ||
@@ -13,0 +13,0 @@ if ((! isArray(args[0]) && ! isObjectLiteral(args[0])) || (! isArray(args[1]) && ! isObjectLiteral(args[1]))) { |
@@ -11,3 +11,3 @@ 'use strict'; | ||
*/ | ||
const diffKey = function (arr1, ...arrays) { | ||
const diffKey = (arr1, ...arrays) => { | ||
const inArrays = key => { | ||
@@ -14,0 +14,0 @@ for (const array of arrays) { |
@@ -6,3 +6,2 @@ 'use strict'; | ||
/** | ||
* @template <K, V> | ||
* Get key, value pairs from any object. | ||
@@ -13,2 +12,3 @@ * | ||
* @returns {IterableIterator.<[K, V]>} | ||
* @template K, V | ||
*/ | ||
@@ -15,0 +15,0 @@ __jymfony.getEntries = function * getEntries(object) { |
@@ -11,3 +11,3 @@ 'use strict'; | ||
*/ | ||
const intersectKey = function (obj, ...arrays) { | ||
const intersectKey = (obj, ...arrays) => { | ||
const inArrays = key => { | ||
@@ -14,0 +14,0 @@ for (const array of arrays) { |
@@ -6,7 +6,7 @@ 'use strict'; | ||
/** | ||
* @param {...} args | ||
* @param {...*} args | ||
* | ||
* @returns {Object} | ||
*/ | ||
const objectMerge = function (...args) { | ||
const objectMerge = (...args) => { | ||
let retArray = args.every(T => isArray(T)); | ||
@@ -13,0 +13,0 @@ |
@@ -10,3 +10,3 @@ 'use strict'; | ||
*/ | ||
const obj2map = function (obj) { | ||
const obj2map = (obj) => { | ||
if (Object.getPrototypeOf(obj) !== Object.prototype) { | ||
@@ -31,3 +31,3 @@ return obj; | ||
*/ | ||
const map2obj = function (map) { | ||
const map2obj = (map) => { | ||
if (! (map instanceof Map)) { | ||
@@ -34,0 +34,0 @@ return map; |
@@ -10,3 +10,3 @@ 'use strict'; | ||
*/ | ||
function serialize(value) { | ||
const serialize = (value) => { | ||
if (null === value) { | ||
@@ -65,3 +65,3 @@ return 'N'; | ||
return 'C[' + reflClass.name + ']:{' + vals.join(';') + (vals.length ? ';' : '') + '}'; | ||
} | ||
}; | ||
@@ -71,3 +71,3 @@ /** | ||
*/ | ||
function unserialize(serialized) { | ||
const unserialize = (serialized) => { | ||
serialized = serialized.toString(); | ||
@@ -213,5 +213,5 @@ let i = 0; | ||
return doUnserialize(); | ||
} | ||
}; | ||
__jymfony.serialize = serialize; | ||
__jymfony.unserialize = unserialize; |
global.__jymfony = global.__jymfony || {}; | ||
let _asyncSupport = undefined; | ||
let _asyncGeneratorSupport = undefined; | ||
let _modernRegex = undefined; | ||
@@ -34,2 +35,25 @@ | ||
/** | ||
* Checks if this node version has async function support. | ||
* | ||
* @returns {boolean} | ||
*/ | ||
static hasAsyncGeneratorFunctionSupport() { | ||
if (undefined === _asyncGeneratorSupport) { | ||
_asyncGeneratorSupport = false; | ||
try { | ||
let fn; | ||
eval('fn = async function * () { }'); | ||
_asyncGeneratorSupport = 'AsyncGeneratorFunction' === (fn.constructor.name || fn.constructor.displayName); | ||
} catch (e) { | ||
if (!(e instanceof SyntaxError)) { | ||
throw e; | ||
} | ||
} | ||
} | ||
return _asyncGeneratorSupport; | ||
} | ||
/** | ||
* Are we running on windows? | ||
@@ -36,0 +60,0 @@ * |
@@ -44,2 +44,11 @@ 'use strict'; | ||
/** | ||
* Check whether the instance argument is a regex. | ||
* | ||
* @param {*} instance | ||
*/ | ||
[Symbol.hasInstance](instance) { | ||
return instance.constructor === RegExp || instance.constructor === __jymfony.RegExp; | ||
} | ||
/** | ||
* @param {string} string | ||
@@ -66,5 +75,7 @@ * | ||
global.RegExp = function RegExp (pattern, flags = undefined) { | ||
return new regexpClass(pattern, flags); | ||
}; | ||
global.RegExp = new Proxy(regexpClass, { | ||
apply(target, thisArg, argArray) { | ||
return new target(...argArray); | ||
}, | ||
}); | ||
} |
@@ -10,5 +10,5 @@ 'use strict'; | ||
*/ | ||
__jymfony.regex_quote = function (str) { | ||
__jymfony.regex_quote = (str) => { | ||
return str.toString() | ||
.replace(/[.\\+*?\[\^\]$(){}=!<>|:-]/g, '\\$&'); | ||
}; |
@@ -31,3 +31,3 @@ 'use strict'; | ||
* | ||
* @returns {number} | ||
* @returns {int} | ||
*/ | ||
@@ -34,0 +34,0 @@ get size() { |
@@ -72,3 +72,3 @@ 'use strict'; | ||
__jymfony.crc32 = function (stringOrBuffer) { | ||
__jymfony.crc32 = (stringOrBuffer) => { | ||
if (! isBuffer(stringOrBuffer)) { | ||
@@ -75,0 +75,0 @@ stringOrBuffer = Buffer.from(stringOrBuffer); |
@@ -11,3 +11,3 @@ 'use strict'; | ||
*/ | ||
__jymfony.escapeshellarg = function escapeshellarg(arg) { | ||
__jymfony.escapeshellarg = (arg) => { | ||
// Discuss at: http://locutus.io/php/escapeshellarg/ | ||
@@ -14,0 +14,0 @@ // Original by: Felix Geisendoerfer (http://www.debuggable.com/felix) |
@@ -13,3 +13,3 @@ 'use strict'; | ||
*/ | ||
__jymfony.levenshtein = function levenshtein(s, t) { | ||
__jymfony.levenshtein = (s, t) => { | ||
// Degenerate cases | ||
@@ -16,0 +16,0 @@ if (s == t) { |
@@ -59,3 +59,3 @@ 'use strict'; | ||
*/ | ||
__jymfony.parse_query_string = function parse_query_string(str) { | ||
__jymfony.parse_query_string = (str) => { | ||
if (null === str) { | ||
@@ -62,0 +62,0 @@ return {}; |
@@ -14,3 +14,3 @@ 'use strict'; | ||
*/ | ||
__jymfony.sprintf = function sprintf (format, ...a) { | ||
__jymfony.sprintf = (format, ...a) => { | ||
// Discuss at: http://locutus.io/php/sprintf/ | ||
@@ -17,0 +17,0 @@ // Original by: Ash Searle (http://hexmen.com/blog/) |
@@ -13,3 +13,3 @@ 'use strict'; | ||
*/ | ||
const _strcspn = function _strcspn(str, mask) { | ||
const _strcspn = (str, mask) => { | ||
let lgth = 0; | ||
@@ -38,3 +38,3 @@ for (let i = 0; i < str.length; i++) { | ||
*/ | ||
__jymfony.strcspn = function strcspn (str, mask, start = 0, length = undefined) { | ||
__jymfony.strcspn = (str, mask, start = 0, length = undefined) => { | ||
if (0 !== start) { | ||
@@ -41,0 +41,0 @@ str = str.substr(start); |
@@ -16,3 +16,3 @@ 'use strict'; | ||
*/ | ||
__jymfony.strip_tags = function strip_tags(input, allowed) { | ||
__jymfony.strip_tags = (input, allowed = undefined) => { | ||
// Discuss at: http://locutus.io/php/strip_tags/ | ||
@@ -19,0 +19,0 @@ // Original by: Kevin van Zonneveld (http://kvz.io) |
@@ -13,3 +13,3 @@ 'use strict'; | ||
*/ | ||
__jymfony.strtr = function strtr(string, replacePairs) { | ||
__jymfony.strtr = (string, replacePairs) => { | ||
const keys = Object.keys(replacePairs); | ||
@@ -16,0 +16,0 @@ if (0 === keys.length) { |
@@ -24,9 +24,2 @@ 'use strict'; | ||
* Replace text within a portion of a string | ||
* | ||
* @param {string|string[]} search | ||
* @param {string|string[]} replacement | ||
* @param {int|int[]} start | ||
* @param {int|int[]} [length] | ||
* | ||
* @returns {string|string[]} | ||
*/ | ||
@@ -33,0 +26,0 @@ __jymfony.substr_replace = (search, replacement, start, length = undefined) => { |
@@ -12,3 +12,3 @@ // Replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') | ||
*/ | ||
__jymfony.rtrim = function rtrim(str, charList = undefined) { | ||
__jymfony.rtrim = (str, charList = undefined) => { | ||
if (undefined === charList) { | ||
@@ -30,3 +30,3 @@ charList = ' \\x09\\x0A\\x0D\\x00\\x0B'; | ||
*/ | ||
__jymfony.ltrim = function ltrim(str, charList = undefined) { | ||
__jymfony.ltrim = (str, charList = undefined) => { | ||
if (undefined === charList) { | ||
@@ -48,4 +48,4 @@ charList = ' \\x09\\x0A\\x0D\\x00\\x0B'; | ||
*/ | ||
__jymfony.trim = function trim(str, charList = undefined) { | ||
__jymfony.trim = (str, charList = undefined) => { | ||
return __jymfony.rtrim(__jymfony.ltrim(str, charList), charList); | ||
}; |
@@ -12,4 +12,4 @@ 'use strict'; | ||
*/ | ||
__jymfony.ucfirst = function ucfirst(string) { | ||
__jymfony.ucfirst = (string) => { | ||
return string.charAt(0).toUpperCase() + string.substring(1); | ||
}; |
@@ -13,3 +13,3 @@ 'use strict'; | ||
*/ | ||
__jymfony.ucwords = function ucwords(string, delimiter = '\\s') { | ||
__jymfony.ucwords = (string, delimiter = '\\s') => { | ||
return string.toString() | ||
@@ -16,0 +16,0 @@ .replace(new RegExp('^([a-z\\u00E0-\\u00FC])|' + delimiter + '([a-z\\u00E0-\\u00FC])', 'g'), $1 => $1.toUpperCase()) |
@@ -18,3 +18,3 @@ 'use strict'; | ||
*/ | ||
__jymfony.version_compare = function version_compare(version1, version2, operator = undefined) { | ||
__jymfony.version_compare = (version1, version2, operator = undefined) => { | ||
// The function first replaces _, - and + with a dot . in the version string and also | ||
@@ -21,0 +21,0 @@ // Inserts dots . before and after any non number so that for example '4.3.2RC1' becomes '4.3.2.RC.1' |
@@ -16,3 +16,3 @@ 'use strict'; | ||
*/ | ||
__jymfony.wordwrap = function wordwrap (str, width = 75, strBreak = '\n', cut = false) { | ||
__jymfony.wordwrap = (str, width = 75, strBreak = '\n', cut = false) => { | ||
// Discuss at: http://locutus.io/php/wordwrap/ | ||
@@ -19,0 +19,0 @@ // Original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) |
{ | ||
"name": "@jymfony/util", | ||
"version": "0.1.0-alpha.13", | ||
"version": "0.1.0-alpha.14", | ||
"description": "Jymfony util functions", | ||
"main": "index.js", | ||
"typings": "types/index.d.ts", | ||
"scripts": { | ||
@@ -19,3 +20,3 @@ "test": "node ./tests.js test/**" | ||
"dependencies": { | ||
"@jymfony/exceptions": "0.1.0-alpha.13" | ||
"@jymfony/exceptions": "0.1.0-alpha.14" | ||
}, | ||
@@ -22,0 +23,0 @@ "devDependencies": { |
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
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
218308
91
6297
3
2
+ Added@jymfony/exceptions@0.1.0-alpha.14(transitive)
- Removed@jymfony/exceptions@0.1.0-alpha.13(transitive)