@deboxsoft/module-core
Advanced tools
Comparing version 1.5.19-6 to 1.5.19-7
115
index.cjs.js
@@ -6,3 +6,26 @@ 'use strict'; | ||
var typedi = require('typedi'); | ||
var changeCase = require('change-case'); | ||
function _interopNamespace(e) { | ||
if (e && e.__esModule) return e; | ||
var n = Object.create(null); | ||
if (e) { | ||
Object.keys(e).forEach(function (k) { | ||
if (k !== 'default') { | ||
var d = Object.getOwnPropertyDescriptor(e, k); | ||
Object.defineProperty(n, k, d.get ? d : { | ||
enumerable: true, | ||
get: function () { | ||
return e[k]; | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
n['default'] = e; | ||
return Object.freeze(n); | ||
} | ||
var changeCase__namespace = /*#__PURE__*/_interopNamespace(changeCase); | ||
class Logger { | ||
@@ -18,2 +41,93 @@ } | ||
function isObject(val) { | ||
return val != null && typeof val === "object" && Array.isArray(val) === false; | ||
} | ||
function isPlainObject(o) { | ||
var ctor, prot; | ||
if (isObject(o) === false) | ||
return false; | ||
ctor = o.constructor; | ||
if (ctor === void 0) | ||
return true; | ||
prot = ctor.prototype; | ||
if (isObject(prot) === false) | ||
return false; | ||
if (prot.hasOwnProperty("isPrototypeOf") === false) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
function isString(value) { | ||
if (value && typeof value.valueOf() === "string") { | ||
return true; | ||
} | ||
return false; | ||
} | ||
function pickBy(object) { | ||
const obj = {}; | ||
for (const key in object) { | ||
if (object[key]) { | ||
obj[key] = object[key]; | ||
} | ||
} | ||
return obj; | ||
} | ||
function debounce(func, wait = 150, immediate = false) { | ||
var timeout; | ||
return function() { | ||
var context = this, args = arguments; | ||
clearTimeout(timeout); | ||
timeout = setTimeout(function() { | ||
timeout = null; | ||
if (!immediate) | ||
func.apply(context, args); | ||
}, wait); | ||
if (immediate && !timeout) | ||
func.apply(context, args); | ||
}; | ||
} | ||
const clamp = (number, boundOne, boundTwo) => { | ||
if (!boundTwo) { | ||
return Math.max(number, boundOne) === boundOne ? number : boundOne; | ||
} else if (Math.min(number, boundOne) === number) { | ||
return boundOne; | ||
} else if (Math.max(number, boundTwo) === number) { | ||
return boundTwo; | ||
} | ||
return number; | ||
}; | ||
function pull(arr, ...removeList) { | ||
var removeSet = new Set(removeList); | ||
return arr.filter(function(el) { | ||
return !removeSet.has(el); | ||
}); | ||
} | ||
function throttle(func, timeFrame) { | ||
var lastTime = 0; | ||
return function() { | ||
var now = Date.now(); | ||
if (now - lastTime >= timeFrame) { | ||
func(); | ||
lastTime = now; | ||
} | ||
}; | ||
} | ||
var index = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), changeCase__namespace, { | ||
isObject: isObject, | ||
isPlainObject: isPlainObject, | ||
isString: isString, | ||
pickBy: pickBy, | ||
debounce: debounce, | ||
clamp: clamp, | ||
pull: pull, | ||
throttle: throttle | ||
})); | ||
Object.defineProperty(exports, 'Container', { | ||
@@ -33,1 +147,2 @@ enumerable: true, | ||
exports.Logger = Logger; | ||
exports.utils = index; |
94
index.js
export { Container, Token } from 'typedi'; | ||
import * as changeCase from 'change-case'; | ||
@@ -13,2 +14,93 @@ class Logger { | ||
export { DeboxError, Logger }; | ||
function isObject(val) { | ||
return val != null && typeof val === "object" && Array.isArray(val) === false; | ||
} | ||
function isPlainObject(o) { | ||
var ctor, prot; | ||
if (isObject(o) === false) | ||
return false; | ||
ctor = o.constructor; | ||
if (ctor === void 0) | ||
return true; | ||
prot = ctor.prototype; | ||
if (isObject(prot) === false) | ||
return false; | ||
if (prot.hasOwnProperty("isPrototypeOf") === false) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
function isString(value) { | ||
if (value && typeof value.valueOf() === "string") { | ||
return true; | ||
} | ||
return false; | ||
} | ||
function pickBy(object) { | ||
const obj = {}; | ||
for (const key in object) { | ||
if (object[key]) { | ||
obj[key] = object[key]; | ||
} | ||
} | ||
return obj; | ||
} | ||
function debounce(func, wait = 150, immediate = false) { | ||
var timeout; | ||
return function() { | ||
var context = this, args = arguments; | ||
clearTimeout(timeout); | ||
timeout = setTimeout(function() { | ||
timeout = null; | ||
if (!immediate) | ||
func.apply(context, args); | ||
}, wait); | ||
if (immediate && !timeout) | ||
func.apply(context, args); | ||
}; | ||
} | ||
const clamp = (number, boundOne, boundTwo) => { | ||
if (!boundTwo) { | ||
return Math.max(number, boundOne) === boundOne ? number : boundOne; | ||
} else if (Math.min(number, boundOne) === number) { | ||
return boundOne; | ||
} else if (Math.max(number, boundTwo) === number) { | ||
return boundTwo; | ||
} | ||
return number; | ||
}; | ||
function pull(arr, ...removeList) { | ||
var removeSet = new Set(removeList); | ||
return arr.filter(function(el) { | ||
return !removeSet.has(el); | ||
}); | ||
} | ||
function throttle(func, timeFrame) { | ||
var lastTime = 0; | ||
return function() { | ||
var now = Date.now(); | ||
if (now - lastTime >= timeFrame) { | ||
func(); | ||
lastTime = now; | ||
} | ||
}; | ||
} | ||
var index = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), changeCase, { | ||
isObject: isObject, | ||
isPlainObject: isPlainObject, | ||
isString: isString, | ||
pickBy: pickBy, | ||
debounce: debounce, | ||
clamp: clamp, | ||
pull: pull, | ||
throttle: throttle | ||
})); | ||
export { DeboxError, Logger, index as utils }; |
{ | ||
"name": "@deboxsoft/module-core", | ||
"version": "1.5.19-6", | ||
"version": "1.5.19-7", | ||
"license": "SEE LICENSE IN LICENSE", | ||
@@ -26,3 +26,3 @@ "maintainers": [ | ||
"build": "yarn r:run-p build:rollup build:tsc", | ||
"build:rollup": "yarn r:rollup -c ../../scripts/rollup/core.config.js", | ||
"build:rollup": "yarn r:rollup -c ../../scripts/rollup/config.js", | ||
"build:tsc": "yarn clean && yarn r:tsc --declaration --emitDeclarationOnly --declarationDir ./types", | ||
@@ -29,0 +29,0 @@ "clean": "yarn r:rimraf types", |
import { Container, Token } from "typedi"; | ||
import { Logger } from "./logger"; | ||
import { DeboxError } from "./Error"; | ||
import * as utils from "./utils"; | ||
export * from "./types"; | ||
export { Container, Token, Logger, DeboxError }; | ||
export { Container, Token, Logger, DeboxError, utils }; |
Sorry, the diff of this file is not supported yet
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
20652
407
21