Skip to content

LLM Resources

@sizium/core - API documentation ​

Classes ​

Sizium ​

Represents the main class for handling package size.

Examples ​

ts
const size = new Sizium( 'chalk' )
const data = await size.get()

console.log(data) // all data
console.log(data.size) // total size on bytes
ts
// Directory input
const size = new Sizium( './' )
const data = await size.get()
ts
// package.json input
const size = new Sizium( './package.json' )
const data = await size.get()
ts
// remote package.json input
const size = new Sizium( 'https://raw.githubusercontent.com/chalk/chalk/refs/heads/main/package.json' )
const data = await size.get()
ts
// package.json string input
const pkg = {name: 'chalk', ... }
const size = new Sizium(JSON.stringify(pkg) )
const data = await size.get()

Constructors ​

new Sizium() ​
ts
new Sizium(input: string): Sizium
Parameters ​
ParameterType
inputstring
Returns ​

Sizium

Methods ​

get() ​
ts
get(): Promise<SiziumResponse>

Retrieves the package information based on the input. It uses either the registry or local search mechanism depending on the input type.

Returns ​

Promise<SiziumResponse>

A promise that resolves with the package response data.

See ​

https://sizium.pigeonposse.com/guide/core/api#siziumresponse

Properties ​

PropertyModifierTypeDefault value
filterpublicSiziumFilterundefined
inputpublicstringundefined
inputTypepublic"string" | "path" | "url" | "json"'string'
pkgpublicundefined | SiziumResponseundefined

SiziumError ​

Extends ​

  • TypedError<SiziumErrorID, { e: unknown; msg: string; }>

Constructors ​

new SiziumError() ​
ts
new SiziumError(message: SiziumErrorID, data?: {
  e: unknown;
  msg: string;
 }): SiziumError
Parameters ​
ParameterType
messageSiziumErrorID
data?object
data.e?unknown
data.msg?string
Returns ​

SiziumError

Inherited from ​

TypedError<SiziumErrorID, { msg : string e? : unknown }>.constructor

Properties ​

PropertyTypeInherited from
dataundefined | { e: unknown; msg: string; }TypedError.data

SiziumFilter ​

A class to filter and sort package information based on various criteria.

Accessors ​

value ​
Get Signature ​
ts
get value(): SiziumResponse
Returns ​

SiziumResponse

Set Signature ​
ts
set value(value: SiziumResponse): void

The package information to be filtered and sorted.

Parameters ​
ParameterType
valueSiziumResponse
Returns ​

void

Constructors ​

new SiziumFilter() ​
ts
new SiziumFilter(value?: SiziumResponse): SiziumFilter
Parameters ​
ParameterType
value?SiziumResponse
Returns ​

SiziumFilter

Methods ​

filter() ​
ts
filter(filter: string): SiziumFilteredResponse

Filters the packages by the given filter string. If no filter string is given, the original package list is returned.

Parameters ​
ParameterTypeDescription
filterstringThe filter string.
Returns ​

SiziumFilteredResponse

An object with the original package list and a filtered list of packages that have a name that matches the given filter string (case-insensitive).

Throws ​

An error if this.value is undefined.

find() ​
ts
find(input: string | {
  name: string;
  version: string;
 }): undefined | PackageInfo

Finds a package in the package list by its name and/or version. If only the name is given, the first package with that name is returned. If the version is also given, the package with that name and version is returned. If no package is found, undefined is returned.

Parameters ​
ParameterTypeDescription
inputstring | { name: string; version: string; }The input to search for. Can be a string with the name of the package or an object with the name and/or version.
Returns ​

undefined | PackageInfo

The package that matches the input or undefined if no package is found.

Examples ​
ts
find( 'chalk' ) // finds the latest version of the chalk package
ts
find( 'chalk@^5' ) // finds the latest version of the chalk package that satisfies the version constraint
ts
find( { name: 'chalk', version: '5.0.0' } ) // finds the chalk package with version 5.0.0
ts
find( { name: 'chalk', version: '^4.0.0' } ) // finds the chalk package with a version that satisfies the version constraint
run() ​
ts
run(opts?: {
  filter: string;
  sort: FilterType;
 }): SiziumResponse | SiziumFilteredResponse

Runs the filter and/or sort on the package list.

Parameters ​
ParameterTypeDescription
opts?objectAn object with options for the filter and/or sort.
opts.filter?stringA string to filter the packages by name.
opts.sort?FilterTypeThe type of sorting to apply to the package list. If not provided, the default sorting is by package size.
Returns ​

SiziumResponse | SiziumFilteredResponse

An object with the filtered and/or sorted package list.

sort() ​
ts
sort(type?: FilterType): SiziumFilter

Sorts the packages based on the given filter type.

Parameters ​
ParameterTypeDescription
type?FilterTypeThe filter type.
Returns ​

SiziumFilter

Resolves to an array of PackageInfo sorted by the given filter type.

Throws ​

An error if this.value is undefined.

sortByDependenceCount() ​
ts
sortByDependenceCount(): SiziumFilter

Sorts the packages by the number of direct dependencies in descending order.

Returns ​

SiziumFilter

The instance of SiziumFilter to allow method chaining.

Throws ​

An error if this.value is undefined.

sortByDependenceLevel() ​
ts
sortByDependenceLevel(): SiziumFilter

Sorts the packages by the level of dependencies in ascending order.

Returns ​

SiziumFilter

The instance of SiziumFilter to allow method chaining.

Throws ​

An error if this.value is undefined.

sortByDependenceSize() ​
ts
sortByDependenceSize(): SiziumFilter

Sorts the packages by the total number of dependencies (both dependencies and devDependencies) in descending order.

Returns ​

SiziumFilter

The instance of SiziumFilter to allow method chaining.

Throws ​

An error if this.value is undefined.

sortByName() ​
ts
sortByName(type: FilterAlphabetType): SiziumFilter

Sorts the packages alphabetically by name.

Parameters ​
ParameterTypeDefault valueDescription
typeFilterAlphabetTypeFILTER_TYPE.ATOZThe sorting order, either 'atoz' (A-Z) or 'ztoa' (Z-A). Default is 'atoz'.
Returns ​

SiziumFilter

The instance of SiziumFilter to allow method chaining.

Throws ​

An error if this.value is undefined.

sortBySize() ​
ts
sortBySize(): SiziumFilter

Sorts the packages by their unpacked size in descending order.

Returns ​

SiziumFilter

The instance of SiziumFilter to allow method chaining.

Throws ​

An error if this.value is undefined.

Properties ​

PropertyModifierTypeDefault valueDescription
typepublic{ ATOZ: 'atoz'; DEPENDENCES_COUNT: 'dep-count'; DEPENDENCES_SIZE: 'dep-size'; LEVEL: 'level'; SIZE: 'size'; ZTOA: 'ztoa'; }FILTER_TYPEType of filter
type.ATOZreadonly"atoz"'atoz'-
type.DEPENDENCES_COUNTreadonly"dep-count"'dep-count'-
type.DEPENDENCES_SIZEreadonly"dep-size"'dep-size'-
type.LEVELreadonly"level"'level'-
type.SIZEreadonly"size"'size'-
type.ZTOAreadonly"ztoa"'ztoa'-

SiziumLocal ​

Represents the class to get the true package size from local enviroment.

Examples ​

ts
// Directory input
const size = new SiziumLocal( './' )
const data = await size.get()
ts
// package.json input
const size = new SiziumLocal( './package.json' )
const data = await size.get()
ts
// remote package.json input
const size = new SiziumLocal( 'https://raw.githubusercontent.com/chalk/chalk/refs/heads/main/package.json' )
const data = await size.get()
ts
// package.json string input
const pkg = {name: 'chalk', ... }
const size = new SiziumLocal(JSON.stringify(pkg) )
const data = await size.get()

Extends ​

  • PackageSuper

Constructors ​

new SiziumLocal() ​
ts
new SiziumLocal(input: string, opts?: PackageSuperOptions): SiziumLocal
Parameters ​
ParameterType
inputstring
opts?PackageSuperOptions
Returns ​

SiziumLocal

Inherited from ​

PackageSuper.constructor

Methods ​

get() ​
ts
get(): Promise<SiziumResponse>

Retrieves the package size information from a local environment. It processes the package data from the input, resolving dependencies and aggregating package data to return a comprehensive size response.

Returns ​

Promise<SiziumResponse>

A promise that resolves with the package response data, including size and dependency information.

Properties ​

PropertyModifierTypeDefault valueInherited from
Errorpublictypeof SiziumErrorSiziumErrorPackageSuper.Error
ERROR_IDpublic{ GETTING_LOCAL_DATA: 'GETTING_LOCAL_DATA'; GETTING_PKG_NAME: 'GETTING_PKG_NAME'; GETTING_REGISTRY_DATA: 'GETTING_REGISTRY_DATA'; INVALID_PKG_NAME: 'INVALID_PKG_NAME'; }ERROR_IDPackageSuper.ERROR_ID
ERROR_ID.GETTING_LOCAL_DATAreadonly"GETTING_LOCAL_DATA"'GETTING_LOCAL_DATA'-
ERROR_ID.GETTING_PKG_NAMEreadonly"GETTING_PKG_NAME"'GETTING_PKG_NAME'-
ERROR_ID.GETTING_REGISTRY_DATAreadonly"GETTING_REGISTRY_DATA"'GETTING_REGISTRY_DATA'-
ERROR_ID.INVALID_PKG_NAMEreadonly"INVALID_PKG_NAME"'INVALID_PKG_NAME'-
inputpublicstringundefinedPackageSuper.input
opts?publicPackageSuperOptionsundefinedPackageSuper.opts

SiziumRegistry ​

Represents the class to get the true package size from the npm registry URL.

Example ​

ts
const size = new SiziumRegistry( 'chalk' )
const data = await size.get()

console.log(data) // all data
console.log(data.size) // total size on bytes

Extends ​

  • PackageSuper

Constructors ​

new SiziumRegistry() ​
ts
new SiziumRegistry(input: string, opts?: PackageSuperOptions): SiziumRegistry
Parameters ​
ParameterType
inputstring
opts?PackageSuperOptions
Returns ​

SiziumRegistry

Inherited from ​

PackageSuper.constructor

Methods ​

get() ​
ts
get(): Promise<SiziumResponse>
Returns ​

Promise<SiziumResponse>

Properties ​

PropertyModifierTypeDefault valueInherited from
Errorpublictypeof SiziumErrorSiziumErrorPackageSuper.Error
ERROR_IDpublic{ GETTING_LOCAL_DATA: 'GETTING_LOCAL_DATA'; GETTING_PKG_NAME: 'GETTING_PKG_NAME'; GETTING_REGISTRY_DATA: 'GETTING_REGISTRY_DATA'; INVALID_PKG_NAME: 'INVALID_PKG_NAME'; }ERROR_IDPackageSuper.ERROR_ID
ERROR_ID.GETTING_LOCAL_DATAreadonly"GETTING_LOCAL_DATA"'GETTING_LOCAL_DATA'-
ERROR_ID.GETTING_PKG_NAMEreadonly"GETTING_PKG_NAME"'GETTING_PKG_NAME'-
ERROR_ID.GETTING_REGISTRY_DATAreadonly"GETTING_REGISTRY_DATA"'GETTING_REGISTRY_DATA'-
ERROR_ID.INVALID_PKG_NAMEreadonly"INVALID_PKG_NAME"'INVALID_PKG_NAME'-
inputpublicstringundefinedPackageSuper.input
opts?publicPackageSuperOptionsundefinedPackageSuper.opts

Functions ​

getPackageSize() ​

ts
function getPackageSize(input: string): Promise<SiziumResponse>

Retrieves the size information of a given package.

Parameters ​

ParameterTypeDescription
inputstringThe input string representing a package name, path, or URL.

Returns ​

Promise<SiziumResponse>

A promise that resolves with the package response data.

Example ​

ts
const data = await getPackageSize( 'chalk' )

console.log(data) // all data
console.log(data.size) // total size on bytes

Type Aliases ​

FilterType ​

ts
type FilterType: typeof FILTER_TYPE[keyof typeof FILTER_TYPE];

PackageInfo ​

ts
type PackageInfo: {
  author: {
     name: string;
     url: string;
    };
  dependencies: PackageJSON["dependencies"];
  description: string;
  devDependencies: PackageJSON["devDependencies"];
  id: string;
  installedBy: string[];
  isCommonJS: boolean;
  isESM: boolean;
  level: number;
  license: string;
  lifeCycleScripts: { [key in lifeCycleScripts]?: string };
  name: string;
  types: boolean;
  unpackedSize: number;
  unpackedSizeKB: number;
  unpackedSizeMB: number;
  url: {
     funding: string;
     homepage: string;
     npm: string;
     repository: string;
     unpkg: string;
    };
  version: string;
};

Type declaration ​

NameTypeDescription
author?{ name: string; url: string; }-
author.namestring-
author.urlstring-
dependencies?PackageJSON["dependencies"]-
description?stringThe description of the package
devDependencies?PackageJSON["devDependencies"]-
idstringThe id of the package: name@version
installedBy?string[]-
isCommonJSbooleanIf the package is written in CommonJS
isESMbooleanIf the package is written in ESM
levelnumberLevel of the dependence installation. Main packages is 0
license?stringThe license of the package
lifeCycleScripts?{ [key in lifeCycleScripts]?: string }Life cycle scripts like: - {post,pre}install - {post,pre}publish - {post,pre}prepare
namestringThe name of the package
typesbooleanIf the package has types
unpackedSizenumberUnpacked size in bytes
unpackedSizeKBnumber-
unpackedSizeMBnumber-
url{ funding: string; homepage: string; npm: string; repository: string; unpkg: string; }-
url.funding?string-
url.homepage?string-
url.npmstring-
url.repository?string-
url.unpkg?string-
versionstringThe version of the package

PackageJSON ​

ts
type PackageJSON: JSONSchemaForNPMPackageJsonFiles & {
  name: string;
  version: string;
};

Type declaration ​

NameType
namestring
versionstring

RegistryPackageJSON ​

ts
type RegistryPackageJSON: PackageJSON & {
[key: string]: Any;   _id: string;
  dist: {
     unpackedSize: number;
    };
};

Type declaration ​

NameType
_idstring
dist?{ unpackedSize: number; }
dist.unpackedSizenumber

SiziumResponse ​

ts
type SiziumResponse: {
  id: string;
  packageNum: number;
  packages: PackageInfo[];
  size: number;
  sizeKB: number;
  sizeMB: number;
};

Type declaration ​

NameTypeDescription
idstring-
packageNumnumberNumber of total packages installed
packagesPackageInfo[]All data from packages
sizenumberSize in bytes
sizeKBnumberSize in kylobytes
sizeMBnumberSize in megabytes

Variables ​

FILTER_TYPE ​

ts
const FILTER_TYPE: {
  ATOZ: 'atoz';
  DEPENDENCES_COUNT: 'dep-count';
  DEPENDENCES_SIZE: 'dep-size';
  LEVEL: 'level';
  SIZE: 'size';
  ZTOA: 'ztoa';
};

Type declaration ​

NameTypeDefault value
ATOZ"atoz"'atoz'
DEPENDENCES_COUNT"dep-count"'dep-count'
DEPENDENCES_SIZE"dep-size"'dep-size'
LEVEL"level"'level'
SIZE"size"'size'
ZTOA"ztoa"'ztoa'