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.2.11
to
0.3.0
+27
-8
lib/index.d.mts

@@ -16,2 +16,4 @@ /**

declare function isAsyncGenerator<T>(value: unknown): value is AsyncGenerator<T>;
/**

@@ -24,2 +26,4 @@ * Type guard that checks if a value is of type never

declare function isNodeJsWriteableStream(value: unknown): value is NodeJS.WritableStream;
/**

@@ -47,2 +51,11 @@ * Check if the given object is a record.

declare class InMemoryFile extends File {
content: string;
constructor(content: string, name: string, { type, endings, lastModified }: {
type?: string;
endings?: 'transparent' | 'native';
lastModified?: number;
});
}
/**

@@ -61,7 +74,10 @@ * A no-operation function that does nothing when called.

*/
declare function noop(): void;
declare function noop(..._args: unknown[]): void;
declare function readableStreamToAsyncIterable<T>(stream: ReadableStream<T>): AsyncIterable<T>;
declare function safeParse<T>(input: unknown): T;
/**
* Safely stringifies any JavaScript value, handling special cases like:
* - Circular references
* - Error objects

@@ -81,7 +97,2 @@ * - BigInt

* ```typescript
* // Handle circular references
* const circular = { a: 1 };
* circular.self = circular;
* safeStringify(circular); // '{"a":1,"self":"[Circular Reference]"}'
*
* // Handle Error objects

@@ -168,2 +179,4 @@ * safeStringify(new Error("test")); // '{"name":"Error","message":"test","stack":"..."}'

type ExclusiveRecord<T, U> = T extends object ? U extends object ? T & Record<Exclude<keyof T, keyof U>, never> : T : T;
/**

@@ -224,2 +237,4 @@ * A type that represents the values of an object type `T`.

type MimeType = 'application/json' | 'application/xml' | 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/html' | 'text/plain' | 'image/jpeg' | 'image/png' | 'video/mp4' | 'audio/mpeg' | 'application/pdf' | 'application/zip' | 'application/octet-stream' | string;
/**

@@ -248,2 +263,6 @@ * A type that "prettifies" the structure of an object type `T`.

export { type Flatten, type FlattenKeys, type FlattenValues, type IdDto, type IdsDto, type InstanceTypeRecord, type MakePropertyOptionalIfChildrenOptional, type Prettify, type RecordTimingDto, type RemoveTrailingSlash, type ReturnTypeRecord, extractArgumentNames, isNever, isRecord, isTrue, noop, safeStringify, sortObjectKeys, stripUndefinedProperties };
type TypeSafeFunction = (...args: never[]) => unknown;
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
export { type ExclusiveRecord, type Flatten, type FlattenKeys, type FlattenValues, type IdDto, type IdsDto, InMemoryFile, type InstanceTypeRecord, type MakePropertyOptionalIfChildrenOptional, type MimeType, type Prettify, type RecordTimingDto, type RemoveTrailingSlash, type ReturnTypeRecord, type TypeSafeFunction, type UnionToIntersection, extractArgumentNames, isAsyncGenerator, isNever, isNodeJsWriteableStream, isRecord, isTrue, noop, readableStreamToAsyncIterable, safeParse, safeStringify, sortObjectKeys, stripUndefinedProperties };

@@ -16,2 +16,4 @@ /**

declare function isAsyncGenerator<T>(value: unknown): value is AsyncGenerator<T>;
/**

@@ -24,2 +26,4 @@ * Type guard that checks if a value is of type never

declare function isNodeJsWriteableStream(value: unknown): value is NodeJS.WritableStream;
/**

@@ -47,2 +51,11 @@ * Check if the given object is a record.

declare class InMemoryFile extends File {
content: string;
constructor(content: string, name: string, { type, endings, lastModified }: {
type?: string;
endings?: 'transparent' | 'native';
lastModified?: number;
});
}
/**

@@ -61,7 +74,10 @@ * A no-operation function that does nothing when called.

*/
declare function noop(): void;
declare function noop(..._args: unknown[]): void;
declare function readableStreamToAsyncIterable<T>(stream: ReadableStream<T>): AsyncIterable<T>;
declare function safeParse<T>(input: unknown): T;
/**
* Safely stringifies any JavaScript value, handling special cases like:
* - Circular references
* - Error objects

@@ -81,7 +97,2 @@ * - BigInt

* ```typescript
* // Handle circular references
* const circular = { a: 1 };
* circular.self = circular;
* safeStringify(circular); // '{"a":1,"self":"[Circular Reference]"}'
*
* // Handle Error objects

@@ -168,2 +179,4 @@ * safeStringify(new Error("test")); // '{"name":"Error","message":"test","stack":"..."}'

type ExclusiveRecord<T, U> = T extends object ? U extends object ? T & Record<Exclude<keyof T, keyof U>, never> : T : T;
/**

@@ -224,2 +237,4 @@ * A type that represents the values of an object type `T`.

type MimeType = 'application/json' | 'application/xml' | 'application/x-www-form-urlencoded' | 'multipart/form-data' | 'text/html' | 'text/plain' | 'image/jpeg' | 'image/png' | 'video/mp4' | 'audio/mpeg' | 'application/pdf' | 'application/zip' | 'application/octet-stream' | string;
/**

@@ -248,2 +263,6 @@ * A type that "prettifies" the structure of an object type `T`.

export { type Flatten, type FlattenKeys, type FlattenValues, type IdDto, type IdsDto, type InstanceTypeRecord, type MakePropertyOptionalIfChildrenOptional, type Prettify, type RecordTimingDto, type RemoveTrailingSlash, type ReturnTypeRecord, extractArgumentNames, isNever, isRecord, isTrue, noop, safeStringify, sortObjectKeys, stripUndefinedProperties };
type TypeSafeFunction = (...args: never[]) => unknown;
type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
export { type ExclusiveRecord, type Flatten, type FlattenKeys, type FlattenValues, type IdDto, type IdsDto, InMemoryFile, type InstanceTypeRecord, type MakePropertyOptionalIfChildrenOptional, type MimeType, type Prettify, type RecordTimingDto, type RemoveTrailingSlash, type ReturnTypeRecord, type TypeSafeFunction, type UnionToIntersection, extractArgumentNames, isAsyncGenerator, isNever, isNodeJsWriteableStream, isRecord, isTrue, noop, readableStreamToAsyncIterable, safeParse, safeStringify, sortObjectKeys, stripUndefinedProperties };

@@ -23,7 +23,12 @@ "use strict";

__export(index_exports, {
InMemoryFile: () => InMemoryFile,
extractArgumentNames: () => extractArgumentNames,
isAsyncGenerator: () => isAsyncGenerator,
isNever: () => isNever,
isNodeJsWriteableStream: () => isNodeJsWriteableStream,
isRecord: () => isRecord,
isTrue: () => isTrue,
noop: () => noop,
readableStreamToAsyncIterable: () => readableStreamToAsyncIterable,
safeParse: () => safeParse,
safeStringify: () => safeStringify,

@@ -63,2 +68,7 @@ sortObjectKeys: () => sortObjectKeys,

// src/guards/isAsyncGenerator.ts
function isAsyncGenerator(value) {
return value != null && typeof value === "object" && "next" in value && typeof value.next === "function" && "return" in value && typeof value.return === "function" && "throw" in value && typeof value.throw === "function";
}
// src/guards/isNever.ts

@@ -69,2 +79,7 @@ function isNever(value) {

// src/guards/isNodeJsWriteableStream.ts
function isNodeJsWriteableStream(value) {
return value != null && typeof value === "object" && "write" in value && typeof value.write === "function" && "end" in value && typeof value.end === "function";
}
// src/guards/isRecord.ts

@@ -80,6 +95,45 @@ function isRecord(obj) {

// src/InMemoryFile.ts
var InMemoryFile = class extends File {
constructor(content, name, {
type,
endings,
lastModified
}) {
super([Buffer.from(content)], name, {
type,
endings,
lastModified
});
this.content = content;
}
};
// src/noop.ts
function noop() {
function noop(..._args) {
}
// src/readableStreamToAsyncIterable.ts
async function* readableStreamToAsyncIterable(stream) {
const reader = stream.getReader();
try {
while (true) {
const { value, done } = await reader.read();
if (done) break;
yield value;
}
} finally {
reader.releaseLock();
}
}
// src/safeParse.ts
function safeParse(input) {
try {
return JSON.parse(input);
} catch {
return input;
}
}
// src/safeStringify.ts

@@ -93,10 +147,3 @@ function safeStringify(arg) {

}
const seen = /* @__PURE__ */ new WeakSet();
const replacer = (key, value) => {
if (value && typeof value === "object") {
if (seen.has(value)) {
return "[Circular Reference]";
}
seen.add(value);
}
if (value instanceof Error) {

@@ -189,7 +236,12 @@ return {

0 && (module.exports = {
InMemoryFile,
extractArgumentNames,
isAsyncGenerator,
isNever,
isNodeJsWriteableStream,
isRecord,
isTrue,
noop,
readableStreamToAsyncIterable,
safeParse,
safeStringify,

@@ -196,0 +248,0 @@ sortObjectKeys,

@@ -29,2 +29,7 @@ // src/extractArgumentNames.ts

// src/guards/isAsyncGenerator.ts
function isAsyncGenerator(value) {
return value != null && typeof value === "object" && "next" in value && typeof value.next === "function" && "return" in value && typeof value.return === "function" && "throw" in value && typeof value.throw === "function";
}
// src/guards/isNever.ts

@@ -35,2 +40,7 @@ function isNever(value) {

// src/guards/isNodeJsWriteableStream.ts
function isNodeJsWriteableStream(value) {
return value != null && typeof value === "object" && "write" in value && typeof value.write === "function" && "end" in value && typeof value.end === "function";
}
// src/guards/isRecord.ts

@@ -46,6 +56,45 @@ function isRecord(obj) {

// src/InMemoryFile.ts
var InMemoryFile = class extends File {
constructor(content, name, {
type,
endings,
lastModified
}) {
super([Buffer.from(content)], name, {
type,
endings,
lastModified
});
this.content = content;
}
};
// src/noop.ts
function noop() {
function noop(..._args) {
}
// src/readableStreamToAsyncIterable.ts
async function* readableStreamToAsyncIterable(stream) {
const reader = stream.getReader();
try {
while (true) {
const { value, done } = await reader.read();
if (done) break;
yield value;
}
} finally {
reader.releaseLock();
}
}
// src/safeParse.ts
function safeParse(input) {
try {
return JSON.parse(input);
} catch {
return input;
}
}
// src/safeStringify.ts

@@ -59,10 +108,3 @@ function safeStringify(arg) {

}
const seen = /* @__PURE__ */ new WeakSet();
const replacer = (key, value) => {
if (value && typeof value === "object") {
if (seen.has(value)) {
return "[Circular Reference]";
}
seen.add(value);
}
if (value instanceof Error) {

@@ -154,7 +196,12 @@ return {

export {
InMemoryFile,
extractArgumentNames,
isAsyncGenerator,
isNever,
isNodeJsWriteableStream,
isRecord,
isTrue,
noop,
readableStreamToAsyncIterable,
safeParse,
safeStringify,

@@ -161,0 +208,0 @@ sortObjectKeys,

{
"name": "@forklaunch/common",
"version": "0.2.11",
"version": "0.3.0",
"description": "Common package for base types, interfaces, implementations.",

@@ -31,11 +31,12 @@ "homepage": "https://github.com/forklaunch/forklaunch-js#readme",

"devDependencies": {
"@eslint/js": "^9.25.0",
"@eslint/js": "^9.27.0",
"@types/node": "^22.15.21",
"depcheck": "^1.4.7",
"eslint": "^9.25.0",
"globals": "^16.0.0",
"tsup": "^8.4.0",
"typedoc": "^0.28.3",
"eslint": "^9.27.0",
"globals": "^16.1.0",
"tsup": "^8.5.0",
"typedoc": "^0.28.4",
"typescript": "^5.8.3",
"typescript-eslint": "^8.30.1",
"vitest": "^3.1.1"
"typescript-eslint": "^8.32.1",
"vitest": "^3.1.4"
},

@@ -42,0 +43,0 @@ "scripts": {