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

@forklaunch/common

Package Overview
Dependencies
Maintainers
1
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forklaunch/common - npm Package Compare versions

Comparing version
0.1.14
to
0.2.0
+64
lib/index.d.mts
declare function isNever(value: never): value is never;
/**
* Check if the given object is a record.
*
* @param {unknown} obj - The object to check.
* @returns {boolean} - True if the object is a record, false otherwise.
*/
declare function isRecord(obj: unknown): obj is Record<string, unknown>;
/**
* A type that represents the values of an object type `T`.
*
* This utility type takes an object type `T` and produces a union of its value types.
*
* @template T - The object type to extract values from.
*/
type FlattenValues<T> = T[keyof T];
/**
* A type that represents the keys of an object type `T`.
*
* This utility type takes an object type `T` and produces a union of its key types.
*
* @template T - The object type to extract keys from.
*/
type FlattenKeys<T> = keyof T;
/**
* A type that flattens an object type `T`.
*
* This utility type takes an object type `T` and recursively flattens it.
*
* @template T - The object type to flatten.
*/
type Flatten<T> = T extends object ? {
[K in keyof T]: Flatten<T[K]>;
} : T;
type AllPropertiesOptional<T> = T extends Partial<T> ? (Partial<T> extends T ? true : false) : false;
type MakePropertyOptionalIfChildrenOptional<T> = {
[K in keyof T as AllPropertiesOptional<T[K]> extends true ? K : never]?: T[K];
} & {
[K in keyof T as AllPropertiesOptional<T[K]> extends true ? never : K]: T[K];
};
/**
* A type that "prettifies" the structure of an object type `T`.
*
* This utility type takes an object type `T` and re-maps its keys and values, effectively creating
* a new type with the same keys and values but without any extra type information or attributes.
* This can be useful for simplifying the displayed type information in development tools.
*
* @template T - The object type to prettify.
*/
type Prettify<T> = {
[K in keyof T]: T[K];
} & {};
type RemoveTrailingSlash<T extends string> = T extends `${infer Route}/` ? Route : T;
declare function extractArgumentNames(func: {
toString(): string;
}): string[];
export { type Flatten, type FlattenKeys, type FlattenValues, type MakePropertyOptionalIfChildrenOptional, type Prettify, type RemoveTrailingSlash, extractArgumentNames, isNever, isRecord };
// src/guards/isNever.ts
function isNever(value) {
return true;
}
// src/guards/isRecord.ts
function isRecord(obj) {
return obj !== null && typeof obj === "object" && !Array.isArray(obj);
}
// src/utils/extractArgumentNames.ts
function extractArgumentNames(func) {
const fnStr = func.toString();
const args = fnStr.match(/\(([^)]*)\)/);
if (!args) return [];
const argsStr = args[1];
const result = [];
let currentArg = "";
let braceCount = 0;
for (let i = 0; i < argsStr.length; i++) {
const char = argsStr[i];
if (char === "{") braceCount++;
if (char === "}") braceCount--;
if (char === "," && braceCount === 0) {
result.push(currentArg.trim());
currentArg = "";
} else {
if (char === " " || char === "\n" || char === " " || char === "\r")
continue;
currentArg += char;
}
}
if (currentArg) {
result.push(currentArg.trim());
}
return result;
}
export {
extractArgumentNames,
isNever,
isRecord
};
+64
-8

@@ -1,8 +0,64 @@

export * from './guards/isNever';
export * from './guards/isRecord';
export * from './types/flatten.types';
export * from './types/makePropertyOptionalIfChildrenOptional.types';
export * from './types/prettify.types';
export * from './types/removeTrailingSlash.types';
export * from './utils/extractArgumentNames';
//# sourceMappingURL=index.d.ts.map
declare function isNever(value: never): value is never;
/**
* Check if the given object is a record.
*
* @param {unknown} obj - The object to check.
* @returns {boolean} - True if the object is a record, false otherwise.
*/
declare function isRecord(obj: unknown): obj is Record<string, unknown>;
/**
* A type that represents the values of an object type `T`.
*
* This utility type takes an object type `T` and produces a union of its value types.
*
* @template T - The object type to extract values from.
*/
type FlattenValues<T> = T[keyof T];
/**
* A type that represents the keys of an object type `T`.
*
* This utility type takes an object type `T` and produces a union of its key types.
*
* @template T - The object type to extract keys from.
*/
type FlattenKeys<T> = keyof T;
/**
* A type that flattens an object type `T`.
*
* This utility type takes an object type `T` and recursively flattens it.
*
* @template T - The object type to flatten.
*/
type Flatten<T> = T extends object ? {
[K in keyof T]: Flatten<T[K]>;
} : T;
type AllPropertiesOptional<T> = T extends Partial<T> ? (Partial<T> extends T ? true : false) : false;
type MakePropertyOptionalIfChildrenOptional<T> = {
[K in keyof T as AllPropertiesOptional<T[K]> extends true ? K : never]?: T[K];
} & {
[K in keyof T as AllPropertiesOptional<T[K]> extends true ? never : K]: T[K];
};
/**
* A type that "prettifies" the structure of an object type `T`.
*
* This utility type takes an object type `T` and re-maps its keys and values, effectively creating
* a new type with the same keys and values but without any extra type information or attributes.
* This can be useful for simplifying the displayed type information in development tools.
*
* @template T - The object type to prettify.
*/
type Prettify<T> = {
[K in keyof T]: T[K];
} & {};
type RemoveTrailingSlash<T extends string> = T extends `${infer Route}/` ? Route : T;
declare function extractArgumentNames(func: {
toString(): string;
}): string[];
export { type Flatten, type FlattenKeys, type FlattenValues, type MakePropertyOptionalIfChildrenOptional, type Prettify, type RemoveTrailingSlash, extractArgumentNames, isNever, isRecord };

@@ -1,7 +0,71 @@

export * from './guards/isNever';
export * from './guards/isRecord';
export * from './types/flatten.types';
export * from './types/makePropertyOptionalIfChildrenOptional.types';
export * from './types/prettify.types';
export * from './types/removeTrailingSlash.types';
export * from './utils/extractArgumentNames';
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// index.ts
var index_exports = {};
__export(index_exports, {
extractArgumentNames: () => extractArgumentNames,
isNever: () => isNever,
isRecord: () => isRecord
});
module.exports = __toCommonJS(index_exports);
// src/guards/isNever.ts
function isNever(value) {
return true;
}
// src/guards/isRecord.ts
function isRecord(obj) {
return obj !== null && typeof obj === "object" && !Array.isArray(obj);
}
// src/utils/extractArgumentNames.ts
function extractArgumentNames(func) {
const fnStr = func.toString();
const args = fnStr.match(/\(([^)]*)\)/);
if (!args) return [];
const argsStr = args[1];
const result = [];
let currentArg = "";
let braceCount = 0;
for (let i = 0; i < argsStr.length; i++) {
const char = argsStr[i];
if (char === "{") braceCount++;
if (char === "}") braceCount--;
if (char === "," && braceCount === 0) {
result.push(currentArg.trim());
currentArg = "";
} else {
if (char === " " || char === "\n" || char === " " || char === "\r")
continue;
currentArg += char;
}
}
if (currentArg) {
result.push(currentArg.trim());
}
return result;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
extractArgumentNames,
isNever,
isRecord
});
+14
-11
{
"name": "@forklaunch/common",
"version": "0.1.14",
"version": "0.2.0",
"description": "Common package for base types, interfaces, implementations.",

@@ -20,3 +20,3 @@ "files": [

"devDependencies": {
"@eslint/js": "^9.16.0",
"@eslint/js": "^9.17.0",
"@types/jest": "^29.5.14",

@@ -26,5 +26,5 @@ "argparse": "^2.0.1",

"brace-expansion": "^4.0.0",
"entities": "^5.0.0",
"eslint": "^9.16.0",
"globals": "^15.13.0",
"entities": "^6.0.0",
"eslint": "^9.17.0",
"globals": "^15.14.0",
"jest": "^29.7.0",

@@ -37,11 +37,12 @@ "linkify-it": "^5.0.0",

"punycode.js": "^2.3.1",
"shiki": "^1.24.0",
"shiki": "^1.26.1",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typedoc": "^0.27.2",
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0",
"tsup": "^8.3.5",
"typedoc": "^0.27.6",
"typescript": "^5.7.3",
"typescript-eslint": "^8.19.1",
"uc.micro": "^2.1.0",
"vitest": "^2.1.8",
"yaml": "^2.6.1"
"yaml": "^2.7.0"
},

@@ -54,2 +55,4 @@ "directories": {

"types": "./lib/index.d.ts",
"import": "./lib/index.mjs",
"require": "./lib/index.js",
"default": "./lib/index.js"

@@ -60,3 +63,3 @@ }

"test": "vitest --passWithNoTests",
"build": "tsc",
"build": "tsc --noEmit && tsup index.ts --format cjs,esm --no-splitting --tsconfig tsconfig.json --outDir lib --dts --clean",
"clean": "rm -rf lib pnpm.lock.yaml node_modules",

@@ -63,0 +66,0 @@ "docs": "typedoc --out docs *",

export declare function isNever(value: never): value is never;
//# sourceMappingURL=isNever.d.ts.map
{"version":3,"file":"isNever.d.ts","sourceRoot":"","sources":["../../src/guards/isNever.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,KAAK,CAEpD"}
export function isNever(value) {
return true;
}
/**
* Check if the given object is a record.
*
* @param {unknown} obj - The object to check.
* @returns {boolean} - True if the object is a record, false otherwise.
*/
export declare function isRecord(obj: unknown): obj is Record<string, unknown>;
//# sourceMappingURL=isRecord.d.ts.map
{"version":3,"file":"isRecord.d.ts","sourceRoot":"","sources":["../../src/guards/isRecord.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAErE"}
/**
* Check if the given object is a record.
*
* @param {unknown} obj - The object to check.
* @returns {boolean} - True if the object is a record, false otherwise.
*/
export function isRecord(obj) {
return obj !== null && typeof obj === 'object' && !Array.isArray(obj);
}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sDAAsD,CAAC;AACrE,cAAc,wBAAwB,CAAC;AACvC,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC"}
/**
* A type that represents the values of an object type `T`.
*
* This utility type takes an object type `T` and produces a union of its value types.
*
* @template T - The object type to extract values from.
*/
export type FlattenValues<T> = T[keyof T];
/**
* A type that represents the keys of an object type `T`.
*
* This utility type takes an object type `T` and produces a union of its key types.
*
* @template T - The object type to extract keys from.
*/
export type FlattenKeys<T> = keyof T;
/**
* A type that flattens an object type `T`.
*
* This utility type takes an object type `T` and recursively flattens it.
*
* @template T - The object type to flatten.
*/
export type Flatten<T> = T extends object ? {
[K in keyof T]: Flatten<T[K]>;
} : T;
//# sourceMappingURL=flatten.types.d.ts.map
{"version":3,"file":"flatten.types.d.ts","sourceRoot":"","sources":["../../src/types/flatten.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GACrC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACjC,CAAC,CAAC"}
type AllPropertiesOptional<T> = T extends Partial<T> ? (Partial<T> extends T ? true : false) : false;
export type MakePropertyOptionalIfChildrenOptional<T> = {
[K in keyof T as AllPropertiesOptional<T[K]> extends true ? K : never]?: T[K];
} & {
[K in keyof T as AllPropertiesOptional<T[K]> extends true ? never : K]: T[K];
};
export {};
//# sourceMappingURL=makePropertyOptionalIfChildrenOptional.types.d.ts.map
{"version":3,"file":"makePropertyOptionalIfChildrenOptional.types.d.ts","sourceRoot":"","sources":["../../src/types/makePropertyOptionalIfChildrenOptional.types.ts"],"names":[],"mappings":"AAAA,KAAK,qBAAqB,CAAC,CAAC,IAC1B,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AAEvE,MAAM,MAAM,sCAAsC,CAAC,CAAC,IAAI;KACrD,CAAC,IAAI,MAAM,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CAC9E,GAAG;KACD,CAAC,IAAI,MAAM,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC7E,CAAC"}
/**
* A type that "prettifies" the structure of an object type `T`.
*
* This utility type takes an object type `T` and re-maps its keys and values, effectively creating
* a new type with the same keys and values but without any extra type information or attributes.
* This can be useful for simplifying the displayed type information in development tools.
*
* @template T - The object type to prettify.
*/
export type Prettify<T> = {
[K in keyof T]: T[K];
} & {};
//# sourceMappingURL=prettify.types.d.ts.map
{"version":3,"file":"prettify.types.d.ts","sourceRoot":"","sources":["../../src/types/prettify.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KACvB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrB,GAAG,EAAE,CAAC"}
export type RemoveTrailingSlash<T extends string> = T extends `${infer Route}/` ? Route : T;
//# sourceMappingURL=removeTrailingSlash.types.d.ts.map
{"version":3,"file":"removeTrailingSlash.types.d.ts","sourceRoot":"","sources":["../../src/types/removeTrailingSlash.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,KAAK,GAAG,GAC3E,KAAK,GACL,CAAC,CAAC"}
export declare function extractArgumentNames(func: {
toString(): string;
}): string[];
//# sourceMappingURL=extractArgumentNames.d.ts.map
{"version":3,"file":"extractArgumentNames.d.ts","sourceRoot":"","sources":["../../src/utils/extractArgumentNames.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IAAE,QAAQ,IAAI,MAAM,CAAA;CAAE,GAAG,MAAM,EAAE,CA+B3E"}
export function extractArgumentNames(func) {
const fnStr = func.toString();
const args = fnStr.match(/\(([^)]*)\)/);
if (!args)
return [];
const argsStr = args[1];
const result = [];
let currentArg = '';
let braceCount = 0;
for (let i = 0; i < argsStr.length; i++) {
const char = argsStr[i];
if (char === '{')
braceCount++;
if (char === '}')
braceCount--;
if (char === ',' && braceCount === 0) {
result.push(currentArg.trim());
currentArg = '';
}
else {
if (char === ' ' || char === '\n' || char === '\t' || char === '\r')
continue;
currentArg += char;
}
}
if (currentArg) {
result.push(currentArg.trim());
}
return result;
}