repo
stringlengths
7
64
file_url
stringlengths
81
338
file_path
stringlengths
5
257
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:25:31
2026-01-05 01:50:38
truncated
bool
2 classes
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/codegen/Emitter.ts
engine/codegen/Emitter.ts
import * as fs from "fs"; export class Emitter { #text = ""; emitCopyrightHeader() { this.#text += ` `; } emit(text: string) { this.#text += text; } writeToFile(filename: string) { fs.writeFileSync(filename, this.#text); // eslint-disable-next-line no-console console.log(`generated $...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/codegen/generateTransformedNodeTree.ts
engine/codegen/generateTransformedNodeTree.ts
import { Definition, getFactoryMethodName } from "./Definition"; import { Emitter } from "./Emitter"; import { getParameterName, getPropertyType, isFactoryUpdateRecastNecessary, isOptional, Property, } from "./Property"; const generateUpdateParameterList = (properties: Array<Property>): string => propertie...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/codegen/Definition.ts
engine/codegen/Definition.ts
import { Property } from "./Property"; export type Definition = { name: string; /** * Can override the syntax kind name (ts.SyntaxKind.XXX) to match the TypeScript API. * Defaults to the value of 'name' */ syntaxKind: string | undefined; /** * Can override the factory method names (createXXX, upd...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/codegen/TextUtils.ts
engine/codegen/TextUtils.ts
export function indent(depth: number): (s: string) => string { const indent = " ".repeat(depth); return (s: string) => s .split("\n") .map((s2) => (s2 === "" ? "" : `${indent}${s2}`)) // don't indent empty strings .join("\n"); } export function toCamelCase(pascalCaseString: string): string { ...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/codegen/generateUpdateNode.ts
engine/codegen/generateUpdateNode.ts
import { Definition, getSyntaxKind } from "./Definition"; import { Emitter } from "./Emitter"; import { getParameterName, getPropertyType, Property } from "./Property"; const recursiveCallParameters = (properties: Array<Property>): string => properties .map((property) => { if (property.modifiable === false...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/codegen/generateMatcher.ts
engine/codegen/generateMatcher.ts
import { Definition } from "./Definition"; import { Emitter } from "./Emitter"; import { getPropertyType } from "./Property"; import { toCamelCase, toPascalCase } from "./TextUtils"; export function generateMatcher(definition: Definition) { const emitter = new Emitter(); emitter.emitCopyrightHeader(); emitter....
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/codegen/generate.ts
engine/codegen/generate.ts
import * as fs from "fs"; import * as path from "path"; import { Definition } from "./Definition"; import { generateCopyShallow } from "./generateCopyShallow"; import { generateForEachChildWithAttribute } from "./generateForEachChildWithAttribute"; import { generateIsNodeStructureEqual } from "./generateIsNodeStructure...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/codegen/generateCopyShallow.ts
engine/codegen/generateCopyShallow.ts
import { Definition, getSyntaxKind } from "./Definition"; import { Emitter } from "./Emitter"; import { getParameterName, Property } from "./Property"; const recursiveCallParameters = (properties: Array<Property>): string => properties.length === 0 ? "" : "{\n" + properties .map((property) => {...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/index.ts
engine/src/index.ts
export * as AssignmentExpression from "./ast/AssignmentExpression"; export { AssignmentOperatorMapping } from "./ast/AssignmentOperatorMapping"; export * as BinaryExpression from "./ast/BinaryExpression"; export { BinaryOperator } from "./ast/BinaryOperator"; export * as BindingElement from "./ast/BindingElement"; expo...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/matchMaybeParenthesized.ts
engine/src/matcher/matchMaybeParenthesized.ts
import ts from "typescript"; import { matchParenthesizedExpression } from "./ast/matchParenthesizedExpression"; import { Context } from "./engine/Context"; import * as p from "./predicate"; export const matchMaybeParenthesized = ( matcher: p.Predicate<ts.Expression, Context> ) => p.recursive<ts.Expression, Context...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/loop.ts
engine/src/matcher/loop.ts
import ts from "typescript"; import * as p from "./predicate"; export const loop = p.or( ts.isForStatement, ts.isForOfStatement, ts.isForInStatement, ts.isDoStatement, ts.isWhileStatement );
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/deduplicateMatches.ts
engine/src/matcher/deduplicateMatches.ts
import ts from "typescript"; import { Context } from "./engine/Context"; import { Match } from "./engine/Match"; /** * Returns subset of matches that do not have ancestor that is root of other match. * This avoids any overlap between different matches (which can lead to conflicting * edit and invalid source code). ...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/statementAfter.ts
engine/src/matcher/statementAfter.ts
import ts from "typescript"; import { ValueContainer } from "./capture/ValueContainer"; import { Context } from "./engine/Context"; import { Predicate } from "./predicate/Predicate"; export function statementAfter( referenceStatementContainer: ValueContainer<ts.Statement>, matcher: Predicate<ts.Node, Context> ) { ...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/captureSelectedNodes.ts
engine/src/matcher/captureSelectedNodes.ts
import ts from "typescript"; import { getId } from "../ast/getId"; import * as NodeRange from "../ast/NodeRange"; import { ValueCapture } from "./capture/ValueCapture"; import { Context } from "./engine/Context"; export const captureSelectedNodes = <T extends ts.Node>({ capture, selectionType, }: { selectionType...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/parent.ts
engine/src/matcher/parent.ts
import ts from "typescript"; import { Context } from "./engine/Context"; import { Predicate } from "./predicate"; import { define } from "./predicate/predicate-wrapper"; export function parent(matcher: Predicate<ts.Node, Context>) { return define("parent", (node: ts.Node, context: Context) => matcher(node.parent...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/doesNotContainNodes.ts
engine/src/matcher/doesNotContainNodes.ts
import ts from "typescript"; import { Context } from "./engine/Context"; import * as p from "./predicate"; export function doesNotContainNodes<T extends ts.Node>( predicate: p.Predicate<T, Context> ) { return p.define( "doesNotContainNodes", p.or(p.isUndefined, p.not(p.isDefined(p.some(predicate)))) ); }...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/resolve.ts
engine/src/matcher/resolve.ts
import * as p from "./predicate"; export function resolve<S, T, CONTEXT>({ resolver, match, debugName = "resolve", }: { resolver: (object: S, context: CONTEXT) => T; match: p.Predicate<T, CONTEXT>; debugName?: string | undefined; }) { return p.define(debugName, (value: S, context: CONTEXT) => match(r...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/matchSelectionRange.ts
engine/src/matcher/matchSelectionRange.ts
import ts from "typescript"; import { trimWhitespaceFromSelection } from "../util/text/trimWhitespaceFromSelection"; import { Context } from "./engine/Context"; import * as p from "./predicate"; /** * Selected range must match node range (ignoring any surround whitespace). */ export function matchSelectionRange() { ...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/index.ts
engine/src/matcher/index.ts
import * as array from "./array"; import * as ast from "./ast"; import * as constraint from "./constraint"; import * as path from "./path"; import * as string from "./string"; import * as type from "./type"; export { captureSelectedNodes } from "./captureSelectedNodes"; export { doesNotContainNodes } from "./doesNotCo...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/isBefore.ts
engine/src/matcher/isBefore.ts
import ts from "typescript"; export function isBefore(reference: ts.Node) { // performance: use .pos instead of .getStart() // (the difference is whitespace/comments and has no effect on node ordering) const referenceStart = reference.pos; return (node: ts.Node) => node.pos < referenceStart; }
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/equalsNodeStructure.ts
engine/src/matcher/equalsNodeStructure.ts
import ts from "typescript"; import { isNodeStructureEqual } from "../ast/isNodeStructureEqual.generated"; import { Context } from "./engine/Context"; import * as p from "./predicate"; export const equalsNodeStructure = (reference: ts.Node) => p.define("equalsNodeStructure", (node: ts.Node, context: Context): boolea...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/hasAncestor.ts
engine/src/matcher/hasAncestor.ts
import ts from "typescript"; import { Context } from "./engine/Context"; import { Predicate } from "./predicate"; import { define } from "./predicate/predicate-wrapper"; export function hasAncestor(predicate: Predicate<ts.Node, Context>) { return define<ts.Node, Context>("hasAncestor", (node, context) => context...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/sharesReferenceAncestor.ts
engine/src/matcher/sharesReferenceAncestor.ts
import _ from "lodash"; import ts from "typescript"; import { Context } from "./engine/Context"; import { Predicate } from "./predicate/Predicate"; export function sharesReferenceAncestor( node: ts.Node, ancestorPredicate: Predicate<ts.Node, Context>, context: Context ): Predicate<ts.Node, Context> { const anc...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/string/index.ts
engine/src/matcher/string/index.ts
export { hasLength } from "./hasLength";
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/string/hasLength.ts
engine/src/matcher/string/hasLength.ts
export function hasLength(length: number) { return (text: string) => text.length === length; }
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/type/maybeNumberType.ts
engine/src/matcher/type/maybeNumberType.ts
import { checkNodeType } from "./checkNodeType"; export const maybeNumberType = checkNodeType((typeSystem, type) => typeSystem.canBeNumber(type) );
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/type/booleanType.ts
engine/src/matcher/type/booleanType.ts
import { checkNodeType } from "./checkNodeType"; export const booleanType = checkNodeType((typeSystem, type) => typeSystem.isBoolean(type) );
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/type/stringType.ts
engine/src/matcher/type/stringType.ts
import { checkNodeType } from "./checkNodeType"; export const stringType = checkNodeType((typeSystem, type) => typeSystem.isString(type) );
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/type/arrayType.ts
engine/src/matcher/type/arrayType.ts
import { checkNodeType } from "./checkNodeType"; export const arrayType = checkNodeType((typeSystem, type) => typeSystem.isArrayType(type) );
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/type/checkNodeType.ts
engine/src/matcher/type/checkNodeType.ts
import ts from "typescript"; import { TypeSystem } from "../../ast/TypeSystem"; import { Context } from "../engine/Context"; export const checkNodeType = (checkType: (typeSystem: TypeSystem, type: ts.Type) => boolean) => (node: ts.Node, { typeSystem }: Context) => { const type = typeSystem.getType(node); r...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/type/numericType.ts
engine/src/matcher/type/numericType.ts
import { checkNodeType } from "./checkNodeType"; export const numericType = checkNodeType((typeSystem, type) => typeSystem.isNumeric(type) );
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/type/index.ts
engine/src/matcher/type/index.ts
export { arrayType as array } from "./arrayType"; export { booleanType as boolean } from "./booleanType"; export { maybeNumberType as maybeNumber } from "./maybeNumberType"; export { numericType as numeric } from "./numericType"; export { stringType as string } from "./stringType";
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildOptionalProperty.ts
engine/src/matcher/builder/buildOptionalProperty.ts
import ts from "typescript"; import { PartialRecord } from "../../util/PartialRecord"; import { Context } from "../engine/Context"; import { Predicate } from "../predicate/Predicate"; import { define } from "../predicate/predicate-wrapper"; export const buildOptionalProperty = <PROPERTY extends string, T>( name: PRO...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildMatchAugmentationNodePropertyMatcher.ts
engine/src/matcher/builder/buildMatchAugmentationNodePropertyMatcher.ts
import ts from "typescript"; import { HardPartialRecord } from "../../util/PartialRecord"; import { Context } from "../engine/Context"; import { Match } from "../engine/Match"; import * as p from "../predicate"; import { Predicate } from "../predicate/Predicate"; export const buildMatchAugmentationNodePropertyMatcher ...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildObject.ts
engine/src/matcher/builder/buildObject.ts
import { Context } from "../engine/Context"; import * as p from "../predicate"; import { Predicate } from "../predicate"; export const buildObject = <IN, OUT extends IN>( debugName: string, typeGuard: (value: IN) => value is OUT, ...matchers: Array<Predicate<OUT, Context> | undefined> ) => p.define(debugName, p....
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildMatchAugmentationCaptureMatcher.ts
engine/src/matcher/builder/buildMatchAugmentationCaptureMatcher.ts
import { HardPartialRecord } from "../../util/PartialRecord"; import { Context } from "../engine/Context"; import { Match } from "../engine/Match"; import * as p from "../predicate"; import { Predicate } from "../predicate/Predicate"; export const buildMatchAugmentationCaptureMatcher = < PROPERTY extends string, V...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildMandatoryPrimitiveProperty.ts
engine/src/matcher/builder/buildMandatoryPrimitiveProperty.ts
import { Context } from "../engine/Context"; import * as p from "../predicate"; import { buildMandatoryProperty } from "./buildMandatoryProperty"; export const buildMandatoryPrimitiveProperty = <PROPERTY extends string, T>( name: PROPERTY, matcher: p.PrimitivePredicateLike<T, Context> ): p.Predicate<Record<PROPERT...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildMatchAugmentationDataMatcher.ts
engine/src/matcher/builder/buildMatchAugmentationDataMatcher.ts
import { HardPartialRecord } from "../../util/PartialRecord"; import { Context } from "../engine/Context"; import { Match } from "../engine/Match"; import * as p from "../predicate"; import { Predicate } from "../predicate/Predicate"; export const buildMatchAugmentationDataMatcher = < PROPERTY extends string, VALU...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildOptionalPrimitiveProperty.ts
engine/src/matcher/builder/buildOptionalPrimitiveProperty.ts
import ts from "typescript"; import { PartialRecord } from "../../util/PartialRecord"; import { Context } from "../engine/Context"; import * as p from "../predicate"; import { Predicate } from "../predicate/Predicate"; import { buildOptionalProperty } from "./buildOptionalProperty"; export const buildOptionalPrimitive...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildVirtualNotNullProperty.ts
engine/src/matcher/builder/buildVirtualNotNullProperty.ts
import ts from "typescript"; import { PartialRecord } from "../../util/PartialRecord"; import { Context } from "../engine/Context"; import * as p from "../predicate"; import { Predicate } from "../predicate/Predicate"; import { define } from "../predicate/predicate-wrapper"; export const buildVirtualNotNullProperty = ...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildMatchAugmentationMatcher.ts
engine/src/matcher/builder/buildMatchAugmentationMatcher.ts
import { MatchAugmentation } from "../../augmentation/MatchAugmentation"; import { Context } from "../engine/Context"; import { AnyMatch } from "../engine/Match"; import * as p from "../predicate"; import { buildAugmentationMatcher } from "./buildAugmentationMatcher"; import { buildVirtualProperty } from "./buildVirtua...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildAugmentationMatcher.ts
engine/src/matcher/builder/buildAugmentationMatcher.ts
import ts from "typescript"; import { Augmentation } from "../../augmentation/Augmentation"; import { Context } from "../engine/Context"; import * as p from "../predicate"; const augmentationChecked = <VALUE, AUGMENTATION extends Augmentation<VALUE>>( augmentation: AUGMENTATION, ...matchers: Array<p.Predicate<VALU...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildKeyword.ts
engine/src/matcher/builder/buildKeyword.ts
import ts from "typescript"; import * as p from "../predicate"; export const buildKeyword = (name: string, kind: ts.SyntaxKind) => p.define(name, (node: ts.Node) => node.kind === kind);
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildMandatoryProperty.ts
engine/src/matcher/builder/buildMandatoryProperty.ts
import { Context } from "../engine/Context"; import { OptionalPredicate } from "../predicate/OptionalPredicate"; import { Predicate } from "../predicate/Predicate"; import { define } from "../predicate/predicate-wrapper"; export const buildMandatoryProperty = <PROPERTY extends string, T>( name: PROPERTY, matcher: ...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildVirtualProperty.ts
engine/src/matcher/builder/buildVirtualProperty.ts
import { Context } from "../engine/Context"; import { OptionalPredicate } from "../predicate/OptionalPredicate"; import { Predicate } from "../predicate/Predicate"; import { resolve } from "../resolve"; export const buildVirtualProperty = <INPUT_TYPE, RESOLVED_TYPE>( name: string, resolver: (node: INPUT_TYPE, cont...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/index.ts
engine/src/matcher/builder/index.ts
export { buildConstraints as constraints } from "./buildConstraints"; export { buildKeyword as keyword } from "./buildKeyword"; export { buildMandatoryExpression as mandatoryExpression } from "./buildMandatoryExpression"; export { buildMandatoryProperty as mandatoryProperty } from "./buildMandatoryProperty"; export { b...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildParentNode.ts
engine/src/matcher/builder/buildParentNode.ts
import ts from "typescript"; import { Context } from "../engine/Context"; import { define } from "../predicate"; import { OptionalPredicate } from "../predicate/OptionalPredicate"; import { Predicate } from "../predicate/Predicate"; export const buildParentNode = < T extends ts.Node & { parent: S }, S extends ts.N...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildConstraints.ts
engine/src/matcher/builder/buildConstraints.ts
import * as p from "../predicate"; export const buildConstraints = p.toConstraintsMatcher;
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/builder/buildMandatoryExpression.ts
engine/src/matcher/builder/buildMandatoryExpression.ts
import ts from "typescript"; import { Context } from "../engine/Context"; import { matchMaybeParenthesized } from "../matchMaybeParenthesized"; import { OptionalPredicate } from "../predicate/OptionalPredicate"; import { Predicate } from "../predicate/Predicate"; import { buildMandatoryProperty } from "./buildMandatory...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/constraint/hasNoReturnStatement.ts
engine/src/matcher/constraint/hasNoReturnStatement.ts
import ts from "typescript"; import { hasDescendant } from "../../ast/hasDescendant"; import { Context } from "../engine/Context"; // TODO exclude nested functions etc. export const hasNoReturnStatement = ( node: | ts.ArrowFunction | ts.FunctionDeclaration | ts.FunctionExpression | ts.MethodDeclarati...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/constraint/isRangeSelection.ts
engine/src/matcher/constraint/isRangeSelection.ts
import ts from "typescript"; import { Context } from "../engine/Context"; export function isRangeSelection(node: ts.Node, context: Context): boolean { const range = context?.selectedRange; return range != null && range.start !== range.end; }
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/constraint/hasExactlyOneElement.ts
engine/src/matcher/constraint/hasExactlyOneElement.ts
export const hasExactlyOneElement = ( list: { length: number } | undefined ): boolean => list?.length === 1;
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/constraint/isInTaggedTemplate.ts
engine/src/matcher/constraint/isInTaggedTemplate.ts
import ts from "typescript"; export const isInTaggedTemplate = (template: ts.TemplateLiteral): boolean => ts.isTaggedTemplateExpression(template.parent);
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/constraint/isTextSelection.ts
engine/src/matcher/constraint/isTextSelection.ts
import ts from "typescript"; import { isPositionInsideNodeText } from "../../ast/isPositionInsideNodeText"; import { Context } from "../engine/Context"; export function isTextSelection( node: ts.Node, context: Context ): node is | ts.StringLiteral | ts.NoSubstitutionTemplateLiteral | ts.TemplateHead | ts.T...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/constraint/isParameterUsedInSubsequentParameterDefaults.ts
engine/src/matcher/constraint/isParameterUsedInSubsequentParameterDefaults.ts
import ts from "typescript"; import { getBindings } from "../../ast/getBindings"; import { getDeclaredBindings } from "../../ast/getDeclaredBindings"; import { getInitializerExpressions } from "../../ast/getInitializerExpressions"; import { Context } from "../engine/Context"; /** * Checks if any of the variables decl...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/constraint/isBindingDeclaredOnce.ts
engine/src/matcher/constraint/isBindingDeclaredOnce.ts
import { Binding } from "../../augmentation/scope/Binding"; export const isBindingDeclaredOnce = (binding: Binding): boolean => !binding.isDeclaredMultipleTimes();
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/constraint/index.ts
engine/src/matcher/constraint/index.ts
export { hasExactlyOneElement } from "./hasExactlyOneElement"; export { hasNoReturnStatement } from "./hasNoReturnStatement"; export { isBindingDeclaredOnce } from "./isBindingDeclaredOnce"; export { isDeclaringIdentifier } from "./isDeclaringIdentifier"; export { isInTaggedTemplate } from "./isInTaggedTemplate"; expo...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/constraint/isDeclaringIdentifier.ts
engine/src/matcher/constraint/isDeclaringIdentifier.ts
import ts from "typescript"; import { Context } from "../engine/Context"; /** * @returns true if the identifier is the declaring node of the binding. */ export const isDeclaringIdentifier = ( identifier: ts.Identifier, context: Context ): boolean => context.getBinding(identifier)?.declaringNodes.includes(ident...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/capture/Capture.ts
engine/src/matcher/capture/Capture.ts
import * as p from "../predicate"; import * as _ from "lodash"; // TODO this should be abstract export class Capture<T> { value: T | undefined; /** * Resets the set capture to it's previous value if the evaluation of the predicate * returned false. * * This can solve the problem where set captures hap...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/capture/SetCapture.ts
engine/src/matcher/capture/SetCapture.ts
import * as _ from "lodash"; import * as p from "../predicate"; import { Capture } from "./Capture"; export class SetCapture<T> extends Capture<T[]> { record<S, C>(predicate: p.Predicate<S, C> = p.any) { return (value: S, context: C) => { const result = predicate(value, context); if (!result) { ...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/capture/ValueCapture.ts
engine/src/matcher/capture/ValueCapture.ts
import _ from "lodash"; import { sameComparator } from "../../util/Comparator"; import { Predicate } from "../predicate/Predicate"; import { Capture } from "./Capture"; import { ContextualComparator } from "./ContextualComparator"; export class ValueCapture<T, C> extends Capture<T> { private readonly compare: Contex...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/capture/ContextualComparator.ts
engine/src/matcher/capture/ContextualComparator.ts
export type ContextualComparator<T, C> = (a: T, b: T, context: C) => boolean;
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/capture/StackCapture.ts
engine/src/matcher/capture/StackCapture.ts
import * as _ from "lodash"; import { sameComparator } from "../../util/Comparator"; import { Predicate } from "../predicate/Predicate"; import { Capture } from "./Capture"; import { ContextualComparator } from "./ContextualComparator"; export class StackCapture<T, C> extends Capture<Array<T>> { private readonly com...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/capture/ValueContainer.ts
engine/src/matcher/capture/ValueContainer.ts
export type ValueContainer<T> = { value: T | undefined; };
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/capture/index.ts
engine/src/matcher/capture/index.ts
import ts from "typescript"; import { createIsNodeStructureEqual, IsNodeStructureEqualOptions, } from "../../ast/isNodeStructureEqual.generated"; import { Context } from "../engine/Context"; import { SetCapture } from "./SetCapture"; import { StackCapture } from "./StackCapture"; import { TemporaryValue } from "./T...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/capture/TemporaryValue.ts
engine/src/matcher/capture/TemporaryValue.ts
import { Context } from "../engine/Context"; import { Predicate } from "../predicate/Predicate"; export class TemporaryValue<T> { value: T | undefined; record(matcher: Predicate<T, Context>): Predicate<T, Context> { return (value: T, context: Context) => { this.value = value; const result = matcher...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/toPrimitivePredicate.ts
engine/src/matcher/predicate/toPrimitivePredicate.ts
import * as _ from "lodash"; import { isIncludedIn } from "./isIncludedIn"; import { Predicate } from "./Predicate"; import { PrimitivePredicateLike } from "./PrimitivePredicateLike"; import { same } from "./same"; export function toPrimitivePredicate<T, C>( value: PrimitivePredicateLike<T, C> ): Predicate<T, C> | u...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/predicate-wrapper.ts
engine/src/matcher/predicate/predicate-wrapper.ts
import * as _ from "lodash"; import { getId } from "../../ast/getId"; import { Predicate } from "./Predicate"; let counter = 0; let debugMode = false; let tree: any; let stack: any[]; export function enableTransformationDebugging() { tree = { children: [] }; stack = [tree]; debugMode = true; counter = 0; }...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/Predicate.ts
engine/src/matcher/predicate/Predicate.ts
/** * Matches a value with potential captures. * * @param value value that should be matched * @param context unmodifiable context that provides additional information * * @returns true if the value could be matched */ export type Predicate<T, C> = (value: T, context: C) => boolean;
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/PrimitivePredicateLike.ts
engine/src/matcher/predicate/PrimitivePredicateLike.ts
import { Predicate } from "./Predicate"; // Intentionally not restricted to string | boolean | number to allow for enum values export type PrimitivePredicateLike<T, C> = | Predicate<T, C> | Array<T> | T | undefined;
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/isDefined.ts
engine/src/matcher/predicate/isDefined.ts
import { and } from "./and"; import { Predicate } from "./Predicate"; import { define } from "./predicate-wrapper"; export function isDefined<T, C>( ...matchers: Predicate<T, C>[] ): Predicate<T | undefined, C> { const additionalChecks = and<T, C>(...matchers); return define( "isDefined", (value: T | und...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/lastArrayElements.ts
engine/src/matcher/predicate/lastArrayElements.ts
import * as _ from "lodash"; import { Predicate } from "./Predicate"; import { define } from "./predicate-wrapper"; import { typeCheck } from "./typeCheck"; export function lastArrayElements<T, C>(...predicates: Predicate<T, C>[]) { return define( "lastArrayElements", typeCheck(_.isArray, (value, context: C)...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/and.ts
engine/src/matcher/predicate/and.ts
import { any } from "./any"; import { Predicate } from "./Predicate"; import { define } from "./predicate-wrapper"; /** * Predicate that is true when all it's available matchers are evaluate to true. * Matchers that are undefined are ignored. */ export function and<T, CONTEXT>( ...matchers: (Predicate<T, CONTEXT>...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/OptionalPredicateArray.ts
engine/src/matcher/predicate/OptionalPredicateArray.ts
import { Predicate } from "./Predicate"; export type OptionalPredicateArray<T, C> = Array<Predicate<T, C>> | undefined;
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/typeCheck.ts
engine/src/matcher/predicate/typeCheck.ts
import { and } from "./and"; import { Predicate } from "./Predicate"; import { define } from "./predicate-wrapper"; export function typeCheck<IN, OUT extends IN, CONTEXT>( typeGuard: (value: IN, context: CONTEXT) => value is OUT, ...matchers: (Predicate<OUT, CONTEXT> | undefined)[] ) { const typeChecked = define...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/any.ts
engine/src/matcher/predicate/any.ts
import _ from "lodash"; export const any = _.constant(true);
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/index.ts
engine/src/matcher/predicate/index.ts
import * as _ from "lodash"; import { and } from "./and"; import { isIncludedIn } from "./isIncludedIn"; import { Predicate } from "./Predicate"; import { define } from "./predicate-wrapper"; import { same } from "./same"; import { typeCheck } from "./typeCheck"; export const empty = define("empty", (value: any) => va...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/firstArrayElements.ts
engine/src/matcher/predicate/firstArrayElements.ts
import * as _ from "lodash"; import { Predicate } from "./Predicate"; import { define } from "./predicate-wrapper"; import { typeCheck } from "./typeCheck"; export function firstArrayElements<T, C>(...predicates: Predicate<T, C>[]) { return define( "firstArrayElements", typeCheck(_.isArray, (value, context: ...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/OptionalPredicate.ts
engine/src/matcher/predicate/OptionalPredicate.ts
import { Predicate } from "./Predicate"; export type OptionalPredicate<T, C> = Predicate<T, C> | undefined;
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/isIncludedIn.ts
engine/src/matcher/predicate/isIncludedIn.ts
import { define } from "./predicate-wrapper"; // TODO rename includedIn to oneOf export function isIncludedIn<T>(...expectedValues: T[]) { const matcher = expectedValues.length > 1 ? (value: T) => expectedValues.includes(value) : (value: T) => expectedValues[0] === value; return define(`isIncluded...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/predicate/same.ts
engine/src/matcher/predicate/same.ts
import { Predicate } from "./Predicate"; import { define } from "./predicate-wrapper"; export function same<T, C>(expectedValue: T): Predicate<T, C> { return define( `same "${expectedValue}"`, (value: T) => expectedValue === value ); }
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/array/index.ts
engine/src/matcher/array/index.ts
export { hasLength } from "./hasLength";
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/array/hasLength.ts
engine/src/matcher/array/hasLength.ts
import ts from "typescript"; export function hasLength(length: number) { return (array: Array<unknown> | ts.NodeArray<any>) => array.length === length; }
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/engine/NodeIndex.ts
engine/src/matcher/engine/NodeIndex.ts
import ts from "typescript"; import { TYPESCRIPT_SYNTAX_KIND_COUNT } from "../../ast/getSyntaxKindLabel"; import { Flags } from "../../util/Flags"; export class NodeIndex { // Performance: Using array for fast syntax kind lookup: readonly nodesBySyntaxKind: Array<Array<ts.Node>> = Array( TYPESCRIPT_SYNTAX_KIN...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/engine/PatternMatcher.ts
engine/src/matcher/engine/PatternMatcher.ts
import ts from "typescript"; import { Augmentation } from "../../augmentation/Augmentation"; import { Capture } from "../capture/Capture"; import { Predicate } from "../predicate/Predicate"; import { Context } from "./Context"; import { AnyMatch } from "./Match"; type Captures<CAPTURES extends Record<string, any>> = {...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/engine/PatternMatcherEngine.ts
engine/src/matcher/engine/PatternMatcherEngine.ts
import ts from "typescript"; import { TypeSystem } from "../../ast/TypeSystem"; import { Augmentation } from "../../augmentation/Augmentation"; import { AugmentationErrorHandler } from "../../augmentation/AugmentationErrorHandler"; import { ScriptMetadata } from "./ScriptMetadata"; import { CancellationToken } from "....
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/engine/NullMatch.ts
engine/src/matcher/engine/NullMatch.ts
import { Match } from "./Match"; export interface NullMatch extends Match<any, any, any> {}
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/engine/ScriptMetadata.ts
engine/src/matcher/engine/ScriptMetadata.ts
import ts from "typescript"; import { Range } from "../../util/text/Range"; import { SupportedExtension } from "../../parser/file-type/FileTypes"; import { Language } from "../../parser/file-type/Language"; import { SourceModuleKind } from "../../parser/file-type/SourceModuleKind"; export class ScriptMetadata { /** ...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/engine/NullMatcher.ts
engine/src/matcher/engine/NullMatcher.ts
import * as p from "../predicate"; import { PatternMatcher } from "./PatternMatcher"; import { NullMatch } from "./NullMatch"; export class NullMatcher extends PatternMatcher<NullMatch> { createPattern() { return { match: p.nothing, captures: {}, }; } }
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/engine/Context.ts
engine/src/matcher/engine/Context.ts
import ts from "typescript"; import { getScopeNode } from "../../ast/ScopeNode"; import { TypeSystem } from "../../ast/TypeSystem"; import { AncestorAugmentation } from "../../augmentation/ancestor/AncestorAugmentation"; import { Augmentation } from "../../augmentation/Augmentation"; import { DescendantAugmentation } f...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/engine/Match.ts
engine/src/matcher/engine/Match.ts
import ts from "typescript"; import { Context } from "./Context"; /** * An identified pattern occurrence in an AST. * * Every match has a key AST node that it matches on and a set of additional captures. */ export interface Match< NODE extends ts.Node, CAPTURES extends Record<string, any>, DATA extends Recor...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/path/trueParent.ts
engine/src/matcher/path/trueParent.ts
import ts from "typescript"; import { Context } from "../engine/Context"; import { Predicate } from "../predicate/Predicate"; export const trueParent = (matcher: Predicate<ts.Node, Context>) => (node: ts.Node, context: Context) => matcher(context.getTrueParent(node), context);
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/path/nextStatement.ts
engine/src/matcher/path/nextStatement.ts
import ts from "typescript"; import { isBlockLike } from "../../ast/BlockLike"; import { isStatement } from "../../ast/Statement"; import { Context } from "../engine/Context"; import { Predicate } from "../predicate/Predicate"; export const nextStatement = (matcher: Predicate<ts.Node, Context>) => (node: ts.Node, ...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/path/optionalProperty.ts
engine/src/matcher/path/optionalProperty.ts
import ts from "typescript"; import { PartialRecord } from "../../util/PartialRecord"; import { Context } from "../engine/Context"; import { Predicate } from "../predicate/Predicate"; export const optionalProperty = <PROPERTY extends string, VALUE>( propertyName: PROPERTY, matcher: Predicate<VALUE | undefine...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/path/parent.ts
engine/src/matcher/path/parent.ts
import ts from "typescript"; import { Context } from "../engine/Context"; import { Predicate } from "../predicate/Predicate"; export const parent = (matcher: Predicate<ts.Node, Context>) => (node: ts.Node, context: Context) => matcher(node.parent, context);
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/path/index.ts
engine/src/matcher/path/index.ts
export { declarationRoot } from "./declarationRoot"; export { nextStatement } from "./nextStatement"; export { optionalProperty } from "./optionalProperty"; export { parent } from "./parent"; export { previousStatement } from "./previousStatement"; export { trueParent } from "./trueParent";
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/path/previousStatement.ts
engine/src/matcher/path/previousStatement.ts
import ts from "typescript"; import { isBlockLike } from "../../ast/BlockLike"; import { isStatement } from "../../ast/Statement"; import { Context } from "../engine/Context"; import { Predicate } from "../predicate/Predicate"; export const previousStatement = (matcher: Predicate<ts.Node, Context>) => (node: ts.No...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/path/declarationRoot.ts
engine/src/matcher/path/declarationRoot.ts
import ts from "typescript"; import { getDeclarationRoot } from "../../ast/getDeclarationRoot"; import { Context } from "../engine/Context"; import { Predicate } from "../predicate/Predicate"; /** * Matches the root of a (potentially complex) declaration from an inner binding * node. */ export const declarationRoot...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/ast/matchNewExpression.ts
engine/src/matcher/ast/matchNewExpression.ts
import ts from "typescript"; import * as b from "../builder"; import { Context } from "../engine/Context"; import * as p from "../predicate"; export function matchNewExpression({ expression = undefined, typeArguments = undefined, argumentsArray = undefined, parent = undefined, constraints = undefined, debu...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false
lgrammel/js-assistant
https://github.com/lgrammel/js-assistant/blob/01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6/engine/src/matcher/ast/matchForStatement.ts
engine/src/matcher/ast/matchForStatement.ts
import ts from "typescript"; import * as p from "../predicate"; import * as b from "../builder"; import { Context } from "../engine/Context"; export function matchForStatement({ initializer = undefined, condition = undefined, incrementor = undefined, statement = undefined, constraints = undefined, debugNam...
typescript
MIT
01d9bce026eeea02efb17f2ce50a1fadb4fd6ba6
2026-01-05T04:58:33.174500Z
false