locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
68 lines (67 loc) • 3.62 kB
TypeScript
import { type PhpAssoc, type PhpCallable, type PhpInput, type PhpList } from './_phpTypes.ts';
interface IniEntry {
local_value?: PhpInput;
}
type LocaleEntry = PhpAssoc<PhpInput> & {
sorting?: (left: PhpInput, right: PhpInput) => number;
};
type LocaleCategoryMap = PhpAssoc<string | undefined>;
interface PhpRuntimeKnownEntryMap {
ini: PhpAssoc<IniEntry | undefined>;
locales: PhpAssoc<LocaleEntry | undefined>;
localeCategories: LocaleCategoryMap;
pointers: PhpList<PhpInput>;
locale_default: string;
locale: string;
uniqidSeed: number;
timeoutStatus: boolean;
last_error_json: number;
strtokleftOver: string;
}
type PhpRuntimeNumberKey = {
[K in keyof PhpRuntimeKnownEntryMap]: PhpRuntimeKnownEntryMap[K] extends number ? K : never;
}[keyof PhpRuntimeKnownEntryMap];
type PhpRuntimeBooleanKey = {
[K in keyof PhpRuntimeKnownEntryMap]: PhpRuntimeKnownEntryMap[K] extends boolean ? K : never;
}[keyof PhpRuntimeKnownEntryMap];
type PhpRuntimeStringKey = {
[K in keyof PhpRuntimeKnownEntryMap]: PhpRuntimeKnownEntryMap[K] extends string ? K : never;
}[keyof PhpRuntimeKnownEntryMap];
interface PhpGlobalProcessLike {
env?: PhpAssoc<string | undefined>;
}
interface PhpGlobalBufferLike {
from?: (...args: PhpInput[]) => PhpInput;
}
interface PhpGlobalKnownEntryMap {
process: PhpGlobalProcessLike;
Buffer: PhpGlobalBufferLike;
}
export interface PhpRuntimeState {
ini: PhpAssoc<IniEntry | undefined>;
locales: PhpAssoc<LocaleEntry | undefined>;
localeCategories: LocaleCategoryMap;
pointers: PhpList<PhpInput>;
locale_default: string | undefined;
}
export declare function ensurePhpRuntimeState(): PhpRuntimeState;
export declare function setPhpLocaleDefault(localeDefault: string): void;
export declare function getPhpRuntimeEntry<TKey extends keyof PhpRuntimeKnownEntryMap>(key: TKey): PhpRuntimeKnownEntryMap[TKey] | undefined;
export declare function getPhpRuntimeEntry(key: string): PhpInput | undefined;
export declare function setPhpRuntimeEntry<TKey extends keyof PhpRuntimeKnownEntryMap>(key: TKey, value: PhpRuntimeKnownEntryMap[TKey]): void;
export declare function setPhpRuntimeEntry(key: string, value: PhpInput): void;
export declare function getPhpRuntimeNumber(key: PhpRuntimeNumberKey, fallback: number): number;
export declare function getPhpRuntimeNumber(key: string, fallback: number): number;
export declare function getPhpRuntimeBoolean(key: PhpRuntimeBooleanKey, fallback: boolean): boolean;
export declare function getPhpRuntimeBoolean(key: string, fallback: boolean): boolean;
export declare function getPhpRuntimeString(key: PhpRuntimeStringKey, fallback: string): string;
export declare function getPhpRuntimeString(key: string, fallback: string): string;
export declare function getPhpGlobalEntry<TKey extends keyof PhpGlobalKnownEntryMap>(key: TKey): PhpGlobalKnownEntryMap[TKey] | undefined;
export declare function getPhpGlobalEntry(key: string): PhpInput | undefined;
export declare function setPhpGlobalEntry(key: string, value: PhpInput): void;
export declare function getPhpGlobalScope(): PhpAssoc<PhpInput>;
export declare function getPhpGlobalCallable<TArgs extends PhpInput[] = PhpInput[], TResult = PhpInput>(key: string): PhpCallable<TArgs, TResult> | undefined;
export declare function getPhpObjectEntry(value: PhpInput, key: string): PhpInput | undefined;
export declare function setPhpObjectEntry(value: PhpInput, key: string, entry: PhpInput): boolean;
export declare function getPhpLocaleGroup(category: string, groupKey: string): PhpAssoc<PhpInput> | undefined;
export {};