UNPKG

js-slang

Version:

Javascript-based implementations of Source, written in Typescript

36 lines (35 loc) 2.01 kB
import type es from 'estree'; import { ArrayMap } from '../dict'; export declare function getModuleDeclarationSource(node: Exclude<es.ModuleDeclaration, es.ExportDefaultDeclaration>): string; export declare function extractIdsFromPattern(pattern: es.Pattern): es.Identifier[]; export declare function getIdsFromDeclaration(decl: es.Declaration, allowNull: true): (es.Identifier | null)[]; export declare function getIdsFromDeclaration(decl: es.Declaration, allowNull?: false): es.Identifier[]; /** * Since Variable declarations in Source programs must be initialized and are guaranteed to only * have 1 declarator, this function unwraps variable declarations and its single declarator * into its id and init */ export declare function getSourceVariableDeclaration(decl: es.VariableDeclaration): { id: es.Identifier; init: es.Expression; loc: es.SourceLocation | null | undefined; }; export declare const getImportedName: (spec: es.ImportSpecifier | es.ImportDefaultSpecifier | es.ExportSpecifier) => string; export declare const speciferToString: (spec: es.ImportSpecifier | es.ImportDefaultSpecifier | es.ExportSpecifier) => string; type BlockBody = (es.Program | es.BlockStatement)['body'][number]; type BlocKBodyWithoutDeclarations = Exclude<BlockBody, es.Declaration>; /** * Returns true if the array of statements doesn't contain any declarations */ export declare function hasNoDeclarations(stmt: BlockBody[]): stmt is BlocKBodyWithoutDeclarations[]; type BlockBodyWithoutImports = Exclude<BlockBody, es.ImportDeclaration>; /** * Returns true if the array of statements doesn't contain any import declarations */ export declare function hasNoImportDeclarations(stmt: BlockBody[]): stmt is BlockBodyWithoutImports[]; /** * Filters out all import declarations from a program, and sorts them by * the module they import from */ export declare function filterImportDeclarations({ body }: es.Program): [ArrayMap<string, es.ImportDeclaration>, BlockBodyWithoutImports[]]; export {};