Sign In

@standardserver/shared

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@standardserver/shared - npm Package Compare versions

Comparing version
0.0.3
to
0.0.4
+11
-3
dist/index.d.mts
declare function toArray<T>(value: T): T extends readonly any[] ? T : Exclude<T, undefined | null>[];
declare const PACKAGE_NAME = "@standardserver/shared";
declare const PACKAGE_VERSION = "0.0.3";
declare const PACKAGE_VERSION = "0.0.4";
/**

@@ -70,3 +70,11 @@ * Generates a unique symbol for the specified name within the package scope.

declare function getOrBind<T extends object, K extends PropertyKey>(target: T, property: K): K extends keyof T ? T[K] : unknown;
interface GetOrBindOptions {
/**
* Whether to bind the function to the target before returning it.
*
* @default true
*/
bind?: boolean;
}
declare function getOrBind<T extends object, K extends PropertyKey>(target: T, property: K, { bind }?: GetOrBindOptions): K extends keyof T ? T[K] : unknown;

@@ -110,2 +118,2 @@ interface AsyncIdQueueCloseOptions {

export { AbortError, AsyncIdQueue, AsyncIteratorClass, PACKAGE_NAME, PACKAGE_VERSION, SequentialIdGenerator, getOrBind, getPackageSymbol, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray, tryDecodeURIComponent };
export type { AsyncCleanupFn, AsyncIdQueueCloseOptions, AsyncIdQueueOptions, AsyncIteratorClassNextFn };
export type { AsyncCleanupFn, AsyncIdQueueCloseOptions, AsyncIdQueueOptions, AsyncIteratorClassNextFn, GetOrBindOptions };
declare function toArray<T>(value: T): T extends readonly any[] ? T : Exclude<T, undefined | null>[];
declare const PACKAGE_NAME = "@standardserver/shared";
declare const PACKAGE_VERSION = "0.0.3";
declare const PACKAGE_VERSION = "0.0.4";
/**

@@ -70,3 +70,11 @@ * Generates a unique symbol for the specified name within the package scope.

declare function getOrBind<T extends object, K extends PropertyKey>(target: T, property: K): K extends keyof T ? T[K] : unknown;
interface GetOrBindOptions {
/**
* Whether to bind the function to the target before returning it.
*
* @default true
*/
bind?: boolean;
}
declare function getOrBind<T extends object, K extends PropertyKey>(target: T, property: K, { bind }?: GetOrBindOptions): K extends keyof T ? T[K] : unknown;

@@ -110,2 +118,2 @@ interface AsyncIdQueueCloseOptions {

export { AbortError, AsyncIdQueue, AsyncIteratorClass, PACKAGE_NAME, PACKAGE_VERSION, SequentialIdGenerator, getOrBind, getPackageSymbol, isAsyncIteratorObject, isTypescriptObject, parseEmptyableJSON, sequential, sleep, stringifyJSON, toArray, tryDecodeURIComponent };
export type { AsyncCleanupFn, AsyncIdQueueCloseOptions, AsyncIdQueueOptions, AsyncIteratorClassNextFn };
export type { AsyncCleanupFn, AsyncIdQueueCloseOptions, AsyncIdQueueOptions, AsyncIteratorClassNextFn, GetOrBindOptions };

@@ -6,3 +6,3 @@ function toArray(value) {

const PACKAGE_NAME = "@standardserver/shared";
const PACKAGE_VERSION = "0.0.3";
const PACKAGE_VERSION = "0.0.4";
function getPackageSymbol(name) {

@@ -124,18 +124,15 @@ return Symbol.for(`${PACKAGE_NAME}@${PACKAGE_VERSION}/${name}`);

const GET_OR_BIND_CACHE = /* @__PURE__ */ new WeakMap();
function getOrBind(target, property) {
function getOrBind(target, property, { bind = true } = {}) {
const value = Reflect.get(target, property);
if (typeof value !== "function") {
if (!bind || typeof value !== "function") {
return value;
}
let cache = GET_OR_BIND_CACHE.get(target);
if (!cache) {
cache = /* @__PURE__ */ new WeakMap();
GET_OR_BIND_CACHE.set(target, cache);
let targetCache = GET_OR_BIND_CACHE.get(value);
if (!targetCache) {
GET_OR_BIND_CACHE.set(value, targetCache = /* @__PURE__ */ new WeakMap());
}
const cached = cache.get(value);
if (cached) {
return cached;
let bound = targetCache.get(target);
if (!bound) {
targetCache.set(target, bound = value.bind(target));
}
const bound = value.bind(target);
cache.set(value, bound);
return bound;

@@ -142,0 +139,0 @@ }

{
"name": "@standardserver/shared",
"type": "module",
"version": "0.0.3",
"version": "0.0.4",
"license": "MIT",

@@ -6,0 +6,0 @@ "homepage": "https://standardserver.dev",