Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@zcodeapp/utils

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zcodeapp/utils - npm Package Compare versions

Comparing version
0.1.0
to
0.2.0
+1
dist/index.d.ts
export * from "./utils";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (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("./utils"), exports);
export declare class Utils {
static randomChars: string;
static RandomString(length?: number): string;
static Clone<T, Y = T>(origin: T): Y;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Utils = void 0;
class Utils {
static RandomString(length = 10) {
return Array.from({ length }, () => Utils.randomChars[Math.floor(Math.random() * Utils.randomChars.length)]).join('');
}
static Clone(origin) {
return JSON.parse(JSON.stringify(origin));
}
}
exports.Utils = Utils;
Utils.randomChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+4
-4
{
"name": "@zcodeapp/utils",
"version": "0.1.0",
"version": "0.2.0",
"description": "Utils for reuse code",

@@ -12,3 +12,3 @@ "main": "dist/index.js",

"test": "node --inspect=0.0.0.0:9229 -r ts-node/register /app/node_modules/jest/bin/jest.js tests",
"build": "tsc && npm run eslint",
"build": "rm -rf dist && tsc && npm run eslint",
"eslint": "eslint --ext .ts ."

@@ -30,3 +30,3 @@ },

"homepage": "https://github.com/zcodeapp/msexpandable#readme",
"gitHead": "814497d396b6c69669fad477a2bfb37f266e03ad",
"gitHead": "d3408b9ce03fdbaf87f359c63365aee31e3fe502",
"devDependencies": {

@@ -36,3 +36,3 @@ "@types/jest": "^29.5.11",

"@typescript-eslint/parser": "^6.16.0",
"@zcodeapp/interfaces": "^0.1.0",
"@zcodeapp/interfaces": "^0.2.0",
"eslint": "^8.56.0",

@@ -39,0 +39,0 @@ "jest": "^29.7.0",

Sorry, the diff of this file is not supported yet

module.exports = {
extends: '../../.eslintrc.base.js'
};
{
"version": "0.2.0",
"configurations": [
{
"name": "Utils Debug",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "docker",
"localRoot": "${workspaceFolder}",
"attachSimplePort": 9229,
"remoteRoot": "/app/src/utils",
"runtimeArgs": [
"compose", "-f", "../../docker-compose.yml",
"run", "--rm",
"--workdir", "/app/src/utils",
"--publish", "9229:9229",
"test"
],
"skipFiles": [
"<node_internals>/**"
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
export * from "./utils";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (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("./utils"), exports);
export declare class Utils {
static randomChars: string;
static RandomString(length?: number): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Utils = void 0;
var Utils = /** @class */ (function () {
function Utils() {
}
Utils.RandomString = function (length) {
if (length === void 0) { length = 10; }
return Array.from({ length: length }, function () { return Utils.randomChars[Math.floor(Math.random() * Utils.randomChars.length)]; }).join('');
};
Utils.randomChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
return Utils;
}());
exports.Utils = Utils;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var src_1 = require("../src");
describe("Utils Test", function () {
it("Test length random string", function () {
expect(src_1.Utils.RandomString()).toHaveLength(10);
expect(src_1.Utils.RandomString(2)).toHaveLength(2);
expect(src_1.Utils.RandomString(20)).toHaveLength(20);
});
it("Test characters random string", function () {
expect(function () {
if (!/^[a-zA-Z0-9]+$/.test(src_1.Utils.RandomString(2000))) {
throw new Error("Random string have wrong characters, rule: ");
}
}).not.toThrow();
});
});
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['<rootDir>/tests/**/*.test.[jt]s?(x)']
};
export * from "./utils"
export class Utils {
public static randomChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
public static RandomString(length: number = 10): string {
return Array.from({ length }, () => Utils.randomChars[Math.floor(Math.random() * Utils.randomChars.length)]).join('');
}
}
import { Utils } from "../src";
describe("Utils Test", () => {
it("Test length random string", () => {
expect(Utils.RandomString()).toHaveLength(10)
expect(Utils.RandomString(2)).toHaveLength(2)
expect(Utils.RandomString(20)).toHaveLength(20)
});
it("Test characters random string", () => {
expect(() => {
if (!/^[a-zA-Z0-9]+$/.test(Utils.RandomString(2000))) {
throw new Error("Random string have wrong characters, rule: ");
}
}).not.toThrow();
});
})
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist"
},
"include": [
"src/**/*",
"tests/**/*"
],
"exclude": [
"node_modules",
"dist"
]
}