npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@e-mc/core

v0.8.11

Published

Core modules for E-mc.

Downloads

749

Readme

@e-mc/core

  • NodeJS 14
  • ES2019

General Usage

Interface

import type { DataSource, LogStatus } from "./squared";

import type { IHost, IModule, ModuleConstructor } from "./index";
import type { CacheOptions, HostInitConfig, JoinQueueOptions, PermissionReadWrite, ResumeThreadOptions, StoreResultOptions, ThreadCountStat } from "./core";
import type { QueryResult, TimeoutAction } from "./db";
import type { AddEventListenerOptions } from "./dom";
import type { StatusType } from "./logger";
import type { Settings } from "./node";
import type { ClientDbSettings, ClientModule, ClientSettings, DbCacheValue, DbCoerceSettings, DbCoerceValue, DbSourceOptions } from "./settings";

interface IHost extends IModule {
    restartable: boolean;
    readonly modules: Set<IModule>;
    readonly subProcesses: Set<IModule>;
    readonly startTime: number;
    using(...items: unknown[] | [boolean, ...unknown[]]): this;
    contains(item: unknown, condition?: (...args: any[]) => boolean): boolean;
    find(name: string): IModule | undefined;
    findAll(name: string): IModule[];
    willLog(name: string): boolean;
    ignoreLog(values: boolean | string | string[]): void;
    collectLog(level?: boolean): LogStatus<StatusType>[];
    willAbort(value: string | IModule): boolean;
    loadModule(name: string, ...args: any[]): IModule | null;
    retain(process: IModule): void;
    release(process: IModule, log?: boolean): boolean;
    restart(...args: unknown[]): void;
    joinQueue(options?: JoinQueueOptions): boolean;
    resumeThread?(options: ResumeThreadOptions): void;
    set host(value);
    get host(): null;
    get config(): Readonly<HostInitConfig>;
    get errorCount(): number;
    get username(): string;
    set done(value);
    get done(): boolean;
    get queued(): boolean;
}

interface HostConstructor extends ModuleConstructor {
    loadSettings(settings: Settings, password?: string): boolean;
    loadSettings(settings: Settings, permission?: PermissionReadWrite, password?: string): boolean;
    isPermission(value: unknown): value is IPermission;
    createPermission(all?: boolean, freeze?: boolean): IPermission;
    kill(username: string, iv: BinaryLike, all: true): number;
    kill(username: string, iv: BinaryLike, pid: number | number[] | boolean): number;
    getThreadCount(full: true): ThreadCountStat;
    getThreadCount(username: string, iv?: BinaryLike): ThreadCountStat;
    getThreadCount(username?: string | boolean, iv?: BinaryLike): number;
    getPermissionFromSettings(): IPermission;
    readonly prototype: IHost;
    new(config?: HostInitConfig): IHost;
}

interface IClient extends IModule<IHost> {
    module: ClientModule;
    init(...args: unknown[]): this;
    getUserSettings(): unknown;
    get settings(): ClientSettings;
    set cacheDir(value: string);
    get cacheDir(): string;
    set extensions(values: unknown[]);
    get extensions(): ((...args: unknown[]) => unknown)[];
}

interface ClientConstructor extends ModuleConstructor {
    readonly prototype: IClient;
    new(module?: ClientModule): IClient;
}

interface IClientDb extends IClient<IHost, ClientModule<ClientDbSettings>> {
    database: DataSource[];
    cacheExpires: number;
    add(item: DataSource, state?: number): void;
    hasCache(source: string, sessionKey?: string, override?: DbCacheValue): boolean;
    hasCoerce(source: string, component: keyof DbCoerceSettings, uuidKey: string | undefined): boolean;
    hasCoerce(source: string, component: keyof DbCoerceSettings, override: DbCoerceValue | null | undefined, credential?: unknown): boolean;
    hasCoerce(source: string, component: keyof DbCoerceSettings, credential?: unknown): boolean;
    getQueryResult(source: string, credential: unknown, queryString: string, renewCache: boolean): QueryResult | undefined;
    getQueryResult(source: string, credential: unknown, queryString: string, sessionKey: string, renewCache?: boolean): QueryResult | undefined;
    getQueryResult(source: string, credential: unknown, queryString: string, options?: CacheOptions | string, renewCache?: boolean): QueryResult | undefined;
    setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, sessionKey: string | undefined): QueryResult;
    setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, options?: CacheOptions | string): QueryResult;
    applyState(items: DataSource | DataSource[], value: number, as?: boolean): void;
    commit(items?: DataSource[]): Promise<boolean>;
    valueOfKey(credential: unknown, name: keyof DbSourceOptions, component?: keyof DbCoerceSettings): unknown;
    settingsOf(source: string, name: keyof DbSourceOptions, component?: keyof DbCoerceSettings): unknown;
    settingsKey(uuidKey: string, name: keyof DbSourceOptions, component?: keyof DbCoerceSettings): unknown;
    get pending(): DataSource[];
    get committed(): DataSource[];
    get failed(): DataSource[];
}

interface ClientDbConstructor extends ClientConstructor<IHost, ClientModule> {
    STORE_RESULT_PARTITION_SIZE: number;
    STORE_RESULT_PARTITION_MULT: number;
    readonly TRANSACTION_ACTIVE: number;
    readonly TRANSACTION_PARTIAL: number;
    readonly TRANSACTION_COMMIT: number;
    readonly TRANSACTION_TERMINATE: number;
    readonly TRANSACTION_ABORT: number;
    readonly TRANSACTION_FAIL: number;
    loadSettings(settings: Pick<Settings, "process" | "memory">, password?: string) : boolean;
    getTimeout(value: number | string | TimeoutAction | undefined): number;
    convertTime(value: number | string): number;
    findResult(source: string, credential: unknown, queryString: string, timeout: number, sessionKey?: string | boolean, renewCache?: boolean): QueryResult | undefined;
    storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, options: StoreResultOptions): QueryResult;
    storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, sessionKey: string, sessionExpires: number): QueryResult;
    storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache: DbCacheValue): QueryResult;
    storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache: DbCacheValue | undefined, options: StoreResultOptions): QueryResult;
    purgeResult(prefix?: string): Promise<number>;
    extractUUID(credential: unknown): string;
    setPoolConfig(value: unknown): void;
    getPoolConfig(source: string): unknown;
    keyOfResult(source: string, credential: unknown, uuidOnly?: boolean): string;
    readonly prototype: IClientDb;
    new(module?: ClientModule, database?: DataSource[]): IClientDb;
}

interface IAbortComponent extends AbortController {
    reset(): void;
    get aborted(): boolean;
}

interface AbortComponentConstructor {
    attach(instance: IAbortComponent, signal: AbortSignal, options?: AddEventListenerOptions): void;
    detach(instance: IAbortComponent, signal: AbortSignal): void;
    readonly prototype: IAbortComponent;
    new(): IAbortComponent;
}

interface IPermission {
    setDiskRead(pathname?: string | string[], enabled?: boolean): void;
    setDiskWrite(pathname?: string | string[], enabled?: boolean): void;
    setUNCRead(pathname?: string | string[], enabled?: boolean): void;
    setUNCWrite(pathname?: string | string[], enabled?: boolean): void;
    getDiskRead(): string | string[];
    getDiskWrite(): string | string[];
    getUNCRead(): string | string[];
    getUNCWrite(): string | string[];
    hasDiskRead(pathname: string): boolean;
    hasDiskWrite(pathname: string): boolean;
    hasUNCRead(pathname: string): boolean;
    hasUNCWrite(pathname: string): boolean;
    get diskRead(): boolean;
    get diskWrite(): boolean;
    get uncRead(): boolean;
    get uncWrite(): boolean;
}

References

LICENSE

MIT