Skip to content

Object API ​

isPlainObject Plain ​

Checks whether a value is a plain object.

Signature ​

ts
export function isPlainObject(value: unknown): value is Record<PropertyKey, unknown>;

Example ​

ts
import { isPlainObject } from "@fast-china/utils";

const result = isPlainObject({});

Input ​

InputTypeRequired / defaultDescription
valueunknownRequiredAny value to check.

Returns ​

ValueTypeDescription
resultvalue is Record<PropertyKey, unknown>true when the prototype is Object.prototype or null.

hasOwn Ownership ​

Safely checks for an object's own property.

Signature ​

ts
export function hasOwn<ObjectType extends object, Key extends PropertyKey>(value: ObjectType, key: Key): key is Key & keyof ObjectType;

Example ​

ts
import { hasOwn } from "@fast-china/utils";

const result = hasOwn({}, "profile");

Input ​

InputTypeRequired / defaultDescription
valueObjectTypeRequiredObject to check.
keyKeyRequiredString, number, or Symbol property key.

Returns ​

ValueTypeDescription
resultkey is Key & keyof ObjectTypetrue for an own property, narrowing the key type.

cloneDeep Clone ​

Recursively creates a deep copy.

Signature ​

ts
export function cloneDeep<Value>(value: Value): Value;

Example ​

ts
import { cloneDeep } from "@fast-china/utils";

const result = cloneDeep({});

Input ​

InputTypeRequired / defaultDescription
valueValueRequiredAny value to clone deeply.

Returns ​

ValueTypeDescription
resultValueNew value of the same type, sharing no clonable nested values; primitives are returned unchanged.

isEqual Compare ​

Deeply compares two values for equivalence.

Signature ​

ts
export function isEqual(left: unknown, right: unknown): boolean;

Example ​

ts
import { isEqual } from "@fast-china/utils";

const result = isEqual([1, 2, 3], [2, 4]);

Input ​

InputTypeRequired / defaultDescription
leftunknownRequiredFirst value to compare.
rightunknownRequiredSecond value to compare.

Returns ​

ValueTypeDescription
resultbooleantrue when the values are deeply equivalent.

pick Pick ​

Performs the corresponding public utility operation.

Signature ​

ts
export function pick<Source extends object, const Keys extends readonly (keyof Source)[]>(
	source: Source,
	keys: Keys
): number extends Keys["length"] ? Partial<Pick<Source, Keys[number]>> : Pick<Source, Keys[number]>;
export function pick<Source extends object>(source: Source, keys: readonly PropertyKey[]): Partial<Source>;

Example ​

ts
import { pick } from "@fast-china/utils";

const result = pick({ id: 1, name: "Fast" }, ["id"] as const);

Input ​

InputTypeRequired / defaultDescription
sourceSourceRequiredSee the signature and method description.
keysreadonly PropertyKey[]RequiredSee the signature and method description.

Returns ​

ValueTypeDescription
resultPartial<Source>Result calculated or created by the method.

omit Omit ​

Performs the corresponding public utility operation.

Signature ​

ts
export function omit<Source extends object, const Keys extends readonly (keyof Source)[]>(
	source: Source,
	keys: Keys
): number extends Keys["length"] ? Omit<Source, Keys[number]> & Partial<Pick<Source, Keys[number]>> : Omit<Source, Keys[number]>;
export function omit<Source extends object>(source: Source, keys: readonly PropertyKey[]): Partial<Source>;

Example ​

ts
import { omit } from "@fast-china/utils";

const result = omit({ id: 1, name: "Fast" }, ["id"] as const);

Input ​

InputTypeRequired / defaultDescription
sourceSourceRequiredSee the signature and method description.
keysreadonly PropertyKey[]RequiredSee the signature and method description.

Returns ​

ValueTypeDescription
resultPartial<Source>Result calculated or created by the method.

omitBy Omit ​

Conditionally omits own enumerable properties.

Signature ​

ts
export function omitBy<Source extends object>(
	source: Source,
	predicate: (value: Source[keyof Source], key: keyof Source, source: Source) => unknown
): Partial<Source>;

Example ​

ts
import { omitBy } from "@fast-china/utils";

const result = omitBy({ id: 1, name: "Fast" }, (_value, key) => key === "id");

Input ​

InputTypeRequired / defaultDescription
sourceSourceRequiredSource object; not mutated.
predicate(value: Source[keyof Source], key: keyof Source, source: Source) => unknownRequiredReceives value, key, and source object; a truthy result omits the property.

Returns ​

ValueTypeDescription
resultPartial<Source>New object containing nonmatching properties.

pickBy Pick ​

Conditionally selects own enumerable properties.

Signature ​

ts
export function pickBy<Source extends object>(
	source: Source,
	predicate: (value: Source[keyof Source], key: keyof Source, source: Source) => unknown
): Partial<Source>;

Example ​

ts
import { pickBy } from "@fast-china/utils";

const result = pickBy({ id: 1, name: "Fast" }, (_value, key) => key === "name");

Input ​

InputTypeRequired / defaultDescription
sourceSourceRequiredSource object; not mutated.
predicate(value: Source[keyof Source], key: keyof Source, source: Source) => unknownRequiredReceives value, key, and source object; a truthy result retains the property.

Returns ​

ValueTypeDescription
resultPartial<Source>New object containing matching properties.

mapValues Map ​

Maps own enumerable property values.

Signature ​

ts
export function mapValues<Source extends object, Result>(
	source: Source,
	mapper: (value: Source[keyof Source], key: keyof Source, source: Source) => Result
): { [Key in keyof Source]: Result };

Example ​

ts
import { mapValues } from "@fast-china/utils";

const result = mapValues({ first: 1, second: 2 }, (value) => value * 2);

Input ​

InputTypeRequired / defaultDescription
sourceSourceRequiredSource object; not mutated.
mapper(value: Source[keyof Source], key: keyof Source, source: Source) => ResultRequiredMapper receiving value, key, and source object.

Returns ​

ValueTypeDescription
result{ [Key in keyof Source]: Result }New object preserving the original keys.

shallowEqual Compare ​

Shallowly compares own enumerable properties using SameValue.

Signature ​

ts
export function shallowEqual(left: object, right: object): boolean;

Example ​

ts
import { shallowEqual } from "@fast-china/utils";

const result = shallowEqual([1, 2, 3], [2, 4]);

Input ​

InputTypeRequired / defaultDescription
leftobjectRequiredFirst object.
rightobjectRequiredSecond object.

Returns ​

ValueTypeDescription
resultbooleantrue when own enumerable key sets and corresponding values match under SameValue.

toQueryString Query ​

Serializes an object into a standard URL query string.

Signature ​

ts
export function toQueryString(value: Readonly<Record<string, QueryValue>>, options: QueryStringOptions = {}): string;

Example ​

ts
import { toQueryString } from "@fast-china/utils";

const result = toQueryString({ page: 1, tag: ["vue", "tsx"] });

Input ​

InputTypeRequired / defaultDescription
valueReadonly<Record<string, QueryValue>>RequiredQuery parameter object.
optionsQueryStringOptionsOptional; defaults to {}Sorting, whitespace encoding, and question-mark prefix options.

Returns ​

ValueTypeDescription
resultstringURL-encoded query string; always empty when there are no parameters.

Clone and dynamic-key boundaries ​

Deep cloning preserves sparse slots, own enumerable string/symbol properties and cycles. Views sharing an ArrayBuffer also share its cloned buffer, with offsets and lengths preserved. Existing unsupported-type behavior remains. pick/omit are shallow operations and dynamic candidate keys are not incorrectly required.

Query encoding boundaries ​

toQueryString uses native encodeURIComponent and preserves form escaping, default + spaces, space: "percent", sorting, and the question-mark prefix option. Lone UTF-16 surrogates in keys or values throw URIError instead of silent U+FFFD replacement; nonfinite numbers still throw RangeError.