You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@nfjs/core

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nfjs/core - npm Package Compare versions

Comparing version
1.0.0
to
1.0.1
+23
-3
api/common.js

@@ -21,3 +21,3 @@ /**

obj.forEach((i) => {
res.push(this.cloneDeep(i));
res.push(cloneDeep(i));
});

@@ -28,3 +28,3 @@ return res;

Object.keys(obj).forEach((k) => {
res[k] = this.cloneDeep(obj[k]);
res[k] = cloneDeep(obj[k]);
});

@@ -101,2 +101,21 @@ } else {

/**
* Очистка объекта с данными от служебных свойств
* @param {Object} obj обрабатываемый объект
* @param {Array<string>} prefixes префиксы свойств, которые нужно удалить из obj
*/
function clearObj(obj, prefixes= ['__','_']) {
if (obj instanceof Object) {
for (const prop in obj) {
if (prefixes.some(prefix => prop.startsWith(prefix))) {
delete obj[prop];
} else {
const o = obj[prop];
if (o instanceof Object) clearObj(o);
}
}
}
return obj;
}
export {

@@ -107,3 +126,4 @@ isEmpty,

getPath,
compose
compose,
clearObj
};

@@ -269,2 +269,9 @@ import fs from 'fs/promises';

function getExtensionsMetaByName(name, extension) {
if(extension) {
return sortedExtensions.find((m) => m.name === extension).meta[name];
}
return sortedExtensions.map(x => x?.meta[name]).filter(x => x);
}
export {

@@ -274,2 +281,3 @@ load,

getSortedExtensions,
getExtensionsMetaByName,
getExtensions,

@@ -276,0 +284,0 @@ nfMenuInfo as menuInfo,

@@ -27,2 +27,77 @@ import assert from 'assert';

});
describe('cloneDeep()', () => {
it('primitives', () => {
// Arrange
const source = {a: 1, b: 'foo', c: true};
// Act
const res = testing.cloneDeep(source);
// Assert
assert.strictEqual(source === res, false);
assert.deepStrictEqual(res, source);
});
it('date', () => {
// Arrange
const source = {a: new Date()};
// Act
const res = testing.cloneDeep(source);
// Assert
assert.strictEqual(source === res, false);
assert.deepStrictEqual(res, source);
assert.strictEqual(res.a instanceof Date, true);
});
it('array', () => {
// Arrange
const source = {a: [['a',1],['b','t'],['c',true]]};
// Act
const res = testing.cloneDeep(source);
// Assert
assert.strictEqual(source === res, false);
assert.deepStrictEqual(res, source);
assert.strictEqual(Array.isArray(res.a), true);
});
it('map', () => {
// Arrange
const source = {a: new Map([['a',1],['b','t'],['c',true]])};
// Act
const res = testing.cloneDeep(source);
// Assert
assert.strictEqual(source === res, false);
assert.deepStrictEqual(res, source);
assert.strictEqual(res.a instanceof Map, true);
});
});
describe('clearObj()', () => {
it('default', () => {
// Arrange
const source = {a_: 1, b__: 'foo', __c: true};
// Act
testing.clearObj(source);
// Assert
assert.strictEqual(source.__c, undefined);
assert.strictEqual(source.b__, 'foo');
assert.strictEqual(source.a_, 1);
});
it('multiple', () => {
// Arrange
const source = {a_: 1, b__: 'foo', __c: true, _d: new Date()};
// Act
testing.clearObj(source, ['__','_']);
// Assert
assert.strictEqual(source.__c, undefined);
assert.strictEqual(source._d, undefined);
assert.strictEqual(source.b__, 'foo');
assert.strictEqual(source.a_, 1);
});
it('recursive', () => {
// Arrange
const source = {a_: 1, b__: {__ba: 'foo', bb__: 'bar'}, __c: true};
// Act
testing.clearObj(source);
// Assert
assert.strictEqual(source.__c, undefined);
assert.strictEqual(source.b__.__ba, undefined);
assert.strictEqual(source.b__.bb__, 'bar');
assert.strictEqual(source.a_, 1);
});
});
});
+1
-1
{
"name": "@nfjs/core",
"version": "1.0.0",
"version": "1.0.1",
"description": "Core",

@@ -5,0 +5,0 @@ "license": "MIT",