Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nocobase/utils

Package Overview
Dependencies
Maintainers
1
Versions
447
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nocobase/utils - npm Package Compare versions

Comparing version 0.7.0-alpha.34 to 0.7.0-alpha.56

1

lib/index.d.ts

@@ -6,2 +6,1 @@ export * from './merge';

export * from './uid';
export * from './umiConfig';

87

lib/index.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./merge"), exports);
__exportStar(require("./mixin"), exports);
__exportStar(require("./mixin/AsyncEmitter"), exports);
__exportStar(require("./registry"), exports);
__exportStar(require("./uid"), exports);
__exportStar(require("./umiConfig"), exports);
//# sourceMappingURL=index.js.map
Object.defineProperty(exports, "__esModule", {
value: true
});
var _merge = require("./merge");
Object.keys(_merge).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _merge[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _merge[key];
}
});
});
var _mixin = require("./mixin");
Object.keys(_mixin).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _mixin[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _mixin[key];
}
});
});
var _AsyncEmitter = require("./mixin/AsyncEmitter");
Object.keys(_AsyncEmitter).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _AsyncEmitter[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _AsyncEmitter[key];
}
});
});
var _registry = require("./registry");
Object.keys(_registry).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _registry[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _registry[key];
}
});
});
var _uid = require("./uid");
Object.keys(_uid).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (key in exports && exports[key] === _uid[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _uid[key];
}
});
});
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.merge = void 0;
const deepmerge_1 = __importDefault(require("deepmerge"));
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.merge = merge;
function _deepmerge() {
const data = _interopRequireDefault(require("deepmerge"));
_deepmerge = function _deepmerge() {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const overwriteMerge = (destinationArray, sourceArray, options) => sourceArray;
function merge(obj1, obj2) {
return (0, deepmerge_1.default)(obj1, obj2, {
arrayMerge: overwriteMerge,
});
}
exports.merge = merge;
//# sourceMappingURL=merge.js.map
return (0, _deepmerge().default)(obj1, obj2, {
arrayMerge: overwriteMerge
});
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AsyncEmitter = void 0;
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
class AsyncEmitter {
emitAsync(event, ...args) {
return __awaiter(this, void 0, void 0, function* () {
// @ts-ignore
const events = this._events;
let callbacks = events[event];
if (!callbacks) {
return false;
}
// helper function to reuse as much code as possible
const run = (cb) => {
switch (args.length) {
// fast cases
case 0:
cb = cb.call(this);
break;
case 1:
cb = cb.call(this, args[0]);
break;
case 2:
cb = cb.call(this, args[0], args[1]);
break;
case 3:
cb = cb.call(this, args[0], args[1], args[2]);
break;
// slower
default:
cb = cb.apply(this, args);
}
if (cb && (cb instanceof Promise || typeof cb.then === 'function')) {
return cb;
}
return Promise.resolve(true);
};
if (typeof callbacks === 'function') {
yield run(callbacks);
}
else if (typeof callbacks === 'object') {
callbacks = callbacks.slice().filter(Boolean);
yield callbacks.reduce((prev, next) => {
return prev.then((res) => {
return run(next).then((result) => Promise.resolve(res.concat(result)));
});
}, Promise.resolve([]));
}
return true;
});
}
emitAsync(event, ...args) {
var _this = this;
return _asyncToGenerator(function* () {
// @ts-ignore
const events = _this._events;
let callbacks = events[event];
if (!callbacks) {
return false;
} // helper function to reuse as much code as possible
const run = cb => {
switch (args.length) {
// fast cases
case 0:
cb = cb.call(_this);
break;
case 1:
cb = cb.call(_this, args[0]);
break;
case 2:
cb = cb.call(_this, args[0], args[1]);
break;
case 3:
cb = cb.call(_this, args[0], args[1], args[2]);
break;
// slower
default:
cb = cb.apply(_this, args);
}
if (cb && (cb instanceof Promise || typeof cb.then === 'function')) {
return cb;
}
return Promise.resolve(true);
};
if (typeof callbacks === 'function') {
yield run(callbacks);
} else if (typeof callbacks === 'object') {
callbacks = callbacks.slice().filter(Boolean);
yield callbacks.reduce((prev, next) => {
return prev.then(res => {
return run(next).then(result => Promise.resolve(res.concat(result)));
});
}, Promise.resolve([]));
}
return true;
})();
}
}
exports.AsyncEmitter = AsyncEmitter;
//# sourceMappingURL=AsyncEmitter.js.map
exports.AsyncEmitter = AsyncEmitter;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyMixins = void 0;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.applyMixins = applyMixins;
function applyMixins(derivedCtor, constructors) {
constructors.forEach((baseCtor) => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||
Object.create(null));
});
constructors.forEach(baseCtor => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach(name => {
Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || Object.create(null));
});
}
exports.applyMixins = applyMixins;
//# sourceMappingURL=index.js.map
});
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Registry = void 0;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.Registry = void 0;
class Registry {
constructor(options = { override: false }) {
this.map = new Map();
this.options = options;
constructor(options = {
override: false
}) {
this.map = new Map();
this.options = void 0;
this.options = options;
}
register(key, value) {
if (!this.options.override && this.map.has(key)) {
throw new Error(`this registry does not allow to override existing keys: "${key}"`);
}
register(key, value) {
if (!this.options.override && this.map.has(key)) {
throw new Error(`this registry does not allow to override existing keys: "${key}"`);
}
this.map.set(key, value);
}
// async import({ directory, extensions = ['.js', '.ts', '.json'] }) {
// const files = await fs.readdir(directory);
// return files.filter(file => extensions.includes(path.extname(file)))
// }
get(key) {
return this.map.get(key);
}
getKeys() {
return this.map.keys();
}
getValues() {
return this.map.values();
}
getEntities() {
return this.map.entries();
}
this.map.set(key, value);
} // async import({ directory, extensions = ['.js', '.ts', '.json'] }) {
// const files = await fs.readdir(directory);
// return files.filter(file => extensions.includes(path.extname(file)))
// }
get(key) {
return this.map.get(key);
}
getKeys() {
return this.map.keys();
}
getValues() {
return this.map.values();
}
getEntities() {
return this.map.entries();
}
}
exports.Registry = Registry;
exports.default = Registry;
//# sourceMappingURL=registry.js.map
var _default = Registry;
exports.default = _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uid = void 0;
let IDX = 36, HEX = '';
while (IDX--)
HEX += IDX.toString(36);
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.uid = uid;
let IDX = 36,
HEX = '';
while (IDX--) HEX += IDX.toString(36);
function uid(len) {
let str = '', num = len || 11;
while (num--)
str += HEX[(Math.random() * 36) | 0];
return str;
}
exports.uid = uid;
//# sourceMappingURL=uid.js.map
let str = '',
num = len || 11;
while (num--) str += HEX[Math.random() * 36 | 0];
return str;
}
{
"name": "@nocobase/utils",
"version": "0.7.0-alpha.34",
"version": "0.7.0-alpha.56",
"main": "lib/index.js",

@@ -13,7 +13,2 @@ "types": "./lib/index.d.ts",

],
"scripts": {
"build": "rimraf -rf lib esm dist && npm run build:cjs && npm run build:esm",
"build:cjs": "tsc --project tsconfig.build.json",
"build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm"
},
"dependencies": {

@@ -23,3 +18,3 @@ "deepmerge": "^4.2.2",

},
"gitHead": "48b2b4bc7bbc39533e461d34d7f026a4ad1a9b5c"
"gitHead": "9a8c05e8fb26029f1d1ba68408a8bddac0e67a76"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc