type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
TypeAliasDeclaration
declare type Pureish = FunctionDeclaration | FunctionExpression | StringLiteral | NumericLiteral | NullLiteral | BooleanLiteral | RegExpLiteral | ArrowFunctionExpression | BigIntLiteral | DecimalLiteral;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration | DeclareClass | DeclareFunction | DeclareInterface | DeclareModule | DeclareModuleExports | DeclareTypeAlias | DeclareOpaqueType | DeclareVariable | DeclareExportDeclaration | DeclareExportAllDeclaration | InterfaceDeclaration | OpaqueType | TypeAlias | EnumDeclaration | TSDeclareFunction | TSInterfaceDeclaration | TSTypeAliasDeclaration | TSEnumDeclaration | TSModuleDeclaration;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type PatternLike = Identifier | RestElement | AssignmentPattern | ArrayPattern | ObjectPattern;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type LVal = Identifier | MemberExpression | RestElement | AssignmentPattern | ArrayPattern | ObjectPattern | TSParameterProperty;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type TSEntityName = Identifier | TSQualifiedName;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type Literal = StringLiteral | NumericLiteral | NullLiteral | BooleanLiteral | RegExpLiteral | TemplateLiteral | BigIntLiteral | DecimalLiteral;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type Immutable = StringLiteral | NumericLiteral | NullLiteral | BooleanLiteral | BigIntLiteral | JSXAttribute | JSXClosingElement | JSXElement | JSXExpressionContainer | JSXSpreadChild | JSXOpeningElement | JSXText | JSXFragment | JSXOpeningFragment | JSXClosingFragment | DecimalLiteral;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type UserWhitespacable = ObjectMethod | ObjectProperty | ObjectTypeInternalSlot | ObjectTypeCallProperty | ObjectTypeIndexer | ObjectTypeProperty | ObjectTypeSpreadProperty;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type Method = ObjectMethod | ClassMethod | ClassPrivateMethod;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type ObjectMember = ObjectMethod | ObjectProperty;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type Property = ObjectProperty | ClassProperty | ClassAccessorProperty | ClassPrivateProperty;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type UnaryLike = UnaryExpression | SpreadElement;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type Pattern = AssignmentPattern | ArrayPattern | ObjectPattern;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type Class = ClassExpression | ClassDeclaration;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type ModuleDeclaration = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type ExportDeclaration = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type ModuleSpecifier = ExportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ImportSpecifier | ExportNamespaceSpecifier | ExportDefaultSpecifier;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type Accessor = ClassAccessorProperty;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type Private = ClassPrivateProperty | ClassPrivateMethod | PrivateName;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type Flow = AnyTypeAnnotation | ArrayTypeAnnotation | BooleanTypeAnnotation | BooleanLiteralTypeAnnotation | NullLiteralTypeAnnotation | ClassImplements | DeclareClass | DeclareFunction | DeclareInterface | DeclareModule | DeclareModuleExports | DeclareTypeAlias | DeclareOpaqueType | DeclareVariable | DeclareExportDeclaration | DeclareExportAllDeclaration | DeclaredPredicate | ExistsTypeAnnotation | FunctionTypeAnnotation | FunctionTypeParam | GenericTypeAnnotation | InferredPredicate | InterfaceExtends | InterfaceDeclaration | InterfaceTypeAnnotation | IntersectionTypeAnnotation | MixedTypeAnnotation | EmptyTypeAnnotation | NullableTypeAnnotation | NumberLiteralTypeAnnotation | NumberTypeAnnotation | ObjectTypeAnnotation | ObjectTypeInternalSlot | ObjectTypeCallProperty | ObjectTypeIndexer | ObjectTypeProperty | ObjectTypeSpreadProperty | OpaqueType | QualifiedTypeIdentifier | StringLiteralTypeAnnotation | StringTypeAnnotation | SymbolTypeAnnotation | ThisTypeAnnotation | TupleTypeAnnotation | TypeofTypeAnnotation | TypeAlias | TypeAnnotation | TypeCastExpression | TypeParameter | TypeParameterDeclaration | TypeParameterInstantiation | UnionTypeAnnotation | Variance | VoidTypeAnnotation | EnumDeclaration | EnumBooleanBody | EnumNumberBody | EnumStringBody | EnumSymbolBody | EnumBooleanMember | EnumNumberMember | EnumStringMember | EnumDefaultedMember | IndexedAccessType | OptionalIndexedAccessType;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type FlowType = AnyTypeAnnotation | ArrayTypeAnnotation | BooleanTypeAnnotation | BooleanLiteralTypeAnnotation | NullLiteralTypeAnnotation | ExistsTypeAnnotation | FunctionTypeAnnotation | GenericTypeAnnotation | InterfaceTypeAnnotation | IntersectionTypeAnnotation | MixedTypeAnnotation | EmptyTypeAnnotation | NullableTypeAnnotation | NumberLiteralTypeAnnotation | NumberTypeAnnotation | ObjectTypeAnnotation | StringLiteralTypeAnnotation | StringTypeAnnotation | SymbolTypeAnnotation | ThisTypeAnnotation | TupleTypeAnnotation | TypeofTypeAnnotation | UnionTypeAnnotation | VoidTypeAnnotation | IndexedAccessType | OptionalIndexedAccessType;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type FlowBaseAnnotation = AnyTypeAnnotation | BooleanTypeAnnotation | NullLiteralTypeAnnotation | MixedTypeAnnotation | EmptyTypeAnnotation | NumberTypeAnnotation | StringTypeAnnotation | SymbolTypeAnnotation | ThisTypeAnnotation | VoidTypeAnnotation;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type FlowDeclaration = DeclareClass | DeclareFunction | DeclareInterface | DeclareModule | DeclareModuleExports | DeclareTypeAlias | DeclareOpaqueType | DeclareVariable | DeclareExportDeclaration | DeclareExportAllDeclaration | InterfaceDeclaration | OpaqueType | TypeAlias;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type FlowPredicate = DeclaredPredicate | InferredPredicate;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type EnumBody = EnumBooleanBody | EnumNumberBody | EnumStringBody | EnumSymbolBody;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type EnumMember = EnumBooleanMember | EnumNumberMember | EnumStringMember | EnumDefaultedMember;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type JSX = JSXAttribute | JSXClosingElement | JSXElement | JSXEmptyExpression | JSXExpressionContainer | JSXSpreadChild | JSXIdentifier | JSXMemberExpression | JSXNamespacedName | JSXOpeningElement | JSXSpreadAttribute | JSXText | JSXFragment | JSXOpeningFragment | JSXClosingFragment;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type Miscellaneous = Noop | Placeholder | V8IntrinsicIdentifier;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type TypeScript = TSParameterProperty | TSDeclareFunction | TSDeclareMethod | TSQualifiedName | TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSPropertySignature | TSMethodSignature | TSIndexSignature | TSAnyKeyword | TSBooleanKeyword | TSBigIntKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSThisType | TSFunctionType | TSConstructorType | TSTypeReference | TSTypePredicate | TSTypeQuery | TSTypeLiteral | TSArrayType | TSTupleType | TSOptionalType | TSRestType | TSNamedTupleMember | TSUnionType | TSIntersectionType | TSConditionalType | TSInferType | TSParenthesizedType | TSTypeOperator | TSIndexedAccessType | TSMappedType | TSLiteralType | TSExpressionWithTypeArguments | TSInterfaceDeclaration | TSInterfaceBody | TSTypeAliasDeclaration | TSAsExpression | TSTypeAssertion | TSEnumDeclaration | TSEnumMember | TSModuleDeclaration | TSModuleBlock | TSImportType | TSImportEqualsDeclaration | TSExternalModuleReference | TSNonNullExpression | TSExportAssignment | TSNamespaceExportDeclaration | TSTypeAnnotation | TSTypeParameterInstantiation | TSTypeParameterDeclaration | TSTypeParameter;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type TSTypeElement = TSCallSignatureDeclaration | TSConstructSignatureDeclaration | TSPropertySignature | TSMethodSignature | TSIndexSignature;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type TSType = TSAnyKeyword | TSBooleanKeyword | TSBigIntKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSThisType | TSFunctionType | TSConstructorType | TSTypeReference | TSTypePredicate | TSTypeQuery | TSTypeLiteral | TSArrayType | TSTupleType | TSOptionalType | TSRestType | TSUnionType | TSIntersectionType | TSConditionalType | TSInferType | TSParenthesizedType | TSTypeOperator | TSIndexedAccessType | TSMappedType | TSLiteralType | TSExpressionWithTypeArguments | TSImportType;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type TSBaseType = TSAnyKeyword | TSBooleanKeyword | TSBigIntKeyword | TSIntrinsicKeyword | TSNeverKeyword | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSStringKeyword | TSSymbolKeyword | TSUndefinedKeyword | TSUnknownKeyword | TSVoidKeyword | TSThisType | TSLiteralType;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type DeprecatedAliases = NumberLiteral$1 | RegexLiteral$1 | RestProperty$1 | SpreadProperty$1;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type ReturnedChild = JSXSpreadChild | JSXElement | JSXFragment | Expression;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
//# sourceMappingURL=toKeyAlias.d.ts.map declare type Scope = { push(value: { id: LVal; kind: "var"; init?: Expression; }): void; buildUndefinedNode(): Node; };
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
//# sourceMappingURL=getOuterBindingIdentifiers.d.ts.map declare type TraversalAncestors = Array<{ node: Node; key: string; index?: number; }>;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type TraversalHandler<T> = (this: undefined, node: Node, parent: TraversalAncestors, state: T) => void;
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
TypeAliasDeclaration
declare type TraversalHandlers<T> = { enter?: TraversalHandler<T>; exit?: TraversalHandler<T>; };
0xBronko/theShop
node_modules/@babel/types/lib/index.d.ts
TypeScript
FunctionDeclaration
/* Copyright 2018 Renzhi Li (aka. Belleve Invis) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ function quadSolve(a: number, b: number, c: number) { // a*x^2 + b*x + c = 0 if (a === 0) { return b === 0 ? [] : [-c / b]; } let D = b * b - 4 * a * c; if (D < 0) { return []; } else if (D === 0) { return [-b / (2 * a)]; } let DSqrt = Math.sqrt(D); return [(-b - DSqrt) / (2 * a), (-b + DSqrt) / (2 * a)]; }
be5invis/primitive-quadify-off-curves
src/estimate.ts
TypeScript
FunctionDeclaration
function cubicRoot(x: number) { return x < 0 ? -Math.pow(-x, 1 / 3) : Math.pow(x, 1 / 3); }
be5invis/primitive-quadify-off-curves
src/estimate.ts
TypeScript
FunctionDeclaration
function cubicSolve(a: number, b: number, c: number, d: number) { // a*x^3 + b*x^2 + c*x + d = 0 if (a === 0) { return quadSolve(b, c, d); } // solve using Cardan's method, which is described in paper of R.W.D. Nickals // http://www.nickalls.org/dick/papers/maths/cubic1993.pdf (doi:10.2307/3619777) let xn = -b / (3 * a); // point of symmetry x coordinate let yn = ((a * xn + b) * xn + c) * xn + d; // point of symmetry y coordinate let deltaSq = (b * b - 3 * a * c) / (9 * a * a); // delta^2 let hSq = 4 * a * a * Math.pow(deltaSq, 3); // h^2 let D3 = yn * yn - hSq; if (D3 > 0) { // 1 real root let D3Sqrt = Math.sqrt(D3); return [xn + cubicRoot((-yn + D3Sqrt) / (2 * a)) + cubicRoot((-yn - D3Sqrt) / (2 * a))]; } else if (D3 === 0) { // 2 real roots let delta1 = cubicRoot(yn / (2 * a)); return [xn - 2 * delta1, xn + delta1]; } // 3 real roots let theta = Math.acos(-yn / Math.sqrt(hSq)) / 3; let delta = Math.sqrt(deltaSq); return [ xn + 2 * delta * Math.cos(theta), xn + 2 * delta * Math.cos(theta + (Math.PI * 2) / 3), xn + 2 * delta * Math.cos(theta + (Math.PI * 4) / 3) ]; }
be5invis/primitive-quadify-off-curves
src/estimate.ts
TypeScript
FunctionDeclaration
function cubicSolveT(e3: number, e2: number, e1: number, e0: number) { const as = cubicSolve(e3, e2, e1, e0); const r = [0, 1]; for (const x of as) if (x > 0 && x < 1) r.push(x); return r; }
be5invis/primitive-quadify-off-curves
src/estimate.ts
TypeScript
FunctionDeclaration
function bez2(a: number, b: number, c: number, t: number) { return mix(mix(a, b, t), mix(b, c, t), t); }
be5invis/primitive-quadify-off-curves
src/estimate.ts
TypeScript
FunctionDeclaration
export function minDistanceToQuad( zx: number, zy: number, ax: number, ay: number, bx: number, by: number, cx: number, cy: number ): number { const aax = ax + cx - 2 * bx; const aay = ay + cy - 2 * by; const bbx = 2 * (bx - ax); const bby = 2 * (by - ay); const e3 = 2 * (aax * aax + aay * aay); const e2 = 3 * (aax * bbx + aay * bby); const e1 = bbx * bbx + bby * bby + 2 * (aax * (ax - zx) + aay * (ay - zy)); const e0 = (ax - zx) * bbx + (ay - zy) * bby; let candidates = cubicSolveT(e3, e2, e1, e0); let minDistance = 1e9; for (const t of candidates) { const tx = bez2(ax, bx, cx, t); const ty = bez2(ay, by, cy, t); const distance = (tx - zx) * (tx - zx) + (ty - zy) * (ty - zy); if (distance < minDistance) minDistance = distance; } return minDistance; }
be5invis/primitive-quadify-off-curves
src/estimate.ts
TypeScript
ClassDeclaration
@NgModule({ declarations: [ ], imports: [ ], providers: [ DocumentRef, BigScreenService ], exports: [ ] }) export class BigScreenModule { }
alxhotel/angular-bigscreen
projects/angular-bigscreen/src/lib/bigscreen.module.ts
TypeScript
ArrowFunction
value => { loadTx.setText(`${Math.floor(value * 100)}%`); }
Aurory-Game/nefties-defenders
client/src/scenes/Preloader.ts
TypeScript
ArrowFunction
() => this.onLoadComplete()
Aurory-Game/nefties-defenders
client/src/scenes/Preloader.ts
TypeScript
ClassDeclaration
export default class Preloader extends Phaser.Scene { constructor() { super(PRELOADER_KEY); } create() { this.load.multiatlas('anims', 'assets/chars/multiatlas.json', 'assets/chars/'); const loadTx = this.add.text(this.scale.width / 2, this.scale.height / 2, '0%', { fontSize: '45px', }).setOrigin(0.5); this.load.animation('animsData', 'assets/chars/anims.json'); this.load.on('progress', value => { loadTx.setText(`${Math.floor(value * 100)}%`); }); this.load.once('complete', () => this.onLoadComplete()); this.load.start(); } onLoadComplete() { this.scene.start(MENU_KEY); } }
Aurory-Game/nefties-defenders
client/src/scenes/Preloader.ts
TypeScript
MethodDeclaration
create() { this.load.multiatlas('anims', 'assets/chars/multiatlas.json', 'assets/chars/'); const loadTx = this.add.text(this.scale.width / 2, this.scale.height / 2, '0%', { fontSize: '45px', }).setOrigin(0.5); this.load.animation('animsData', 'assets/chars/anims.json'); this.load.on('progress', value => { loadTx.setText(`${Math.floor(value * 100)}%`); }); this.load.once('complete', () => this.onLoadComplete()); this.load.start(); }
Aurory-Game/nefties-defenders
client/src/scenes/Preloader.ts
TypeScript
MethodDeclaration
onLoadComplete() { this.scene.start(MENU_KEY); }
Aurory-Game/nefties-defenders
client/src/scenes/Preloader.ts
TypeScript
FunctionDeclaration
function randomString(len: number) { let text = ""; const charset = "abcdefghijklmnopqrstuvwxyz"; for (let charIndex = 0; charIndex < len; charIndex++) { text += charset.charAt(Math.floor(Math.random() * charset.length)); } return text; }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
FunctionDeclaration
function replaceAt(str: string, index: number, character: string) { return ( str.substr(0, index) + character + str.substr(index + character.length) ); }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
FunctionDeclaration
function solveTest( singleSelectionName: keyof typeof Genetic.Select1, pairWiseSelectionName: keyof typeof Genetic.Select2, config: Partial<Configuration> ) { const singleSelection: SingleSelection<Entity> = Genetic.Select1[singleSelectionName]; const pairWiseSelection: PairWiseSelection<Entity> = Genetic.Select2[pairWiseSelectionName]; const title = singleSelectionName + ", " + pairWiseSelectionName; it(title, done => { jest.setTimeout(10000); expect.assertions(1); const userData: UserData = { solution: "thisisthesolution", }; class CustomPhraseGenetic extends PhraseGenetic { public select1: SingleSelection<Entity> = singleSelection; public select2: PairWiseSelection<Entity> = pairWiseSelection; public notification({ population: pop, generation, isFinished, }: { population: Population<Entity>; generation: number; stats: Stats; isFinished: boolean; }) { if (isFinished) { expect(pop[0].entity).toBe(this.userData.solution); done(); } } } const genetic = new CustomPhraseGenetic(config, userData); return genetic.evolve(); }); }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
ArrowFunction
done => { jest.setTimeout(10000); expect.assertions(1); const userData: UserData = { solution: "thisisthesolution", }; class CustomPhraseGenetic extends PhraseGenetic { public select1: SingleSelection<Entity> = singleSelection; public select2: PairWiseSelection<Entity> = pairWiseSelection; public notification({ population: pop, generation, isFinished, }: { population: Population<Entity>; generation: number; stats: Stats; isFinished: boolean; }) { if (isFinished) { expect(pop[0].entity).toBe(this.userData.solution); done(); } } } const genetic = new CustomPhraseGenetic(config, userData); return genetic.evolve(); }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
ArrowFunction
() => { const config: Partial<Configuration> = { crossover: 0.4, iterations: 2000, mutation: 0.3, size: 20, }; const singleSelectionName = "Tournament3"; const pairWiseSelectionName = "Tournament3"; solveTest(singleSelectionName as any, pairWiseSelectionName as any, config); // Object.keys(Genetic.Select1).forEach(singleSelectionName => { // Object.keys(Genetic.Select2).forEach(pairWiseSelectionName => { // solveTest( // singleSelectionName as any, // pairWiseSelectionName as any, // config // ); // }); // }); }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
ClassDeclaration
abstract class PhraseGenetic extends Genetic.Genetic<Entity, UserData> { public optimize: Optimize.OptimizeFun = Genetic.Optimize.Maximize; public seed() { function randomString(len: number) { let text = ""; const charset = "abcdefghijklmnopqrstuvwxyz"; for (let charIndex = 0; charIndex < len; charIndex++) { text += charset.charAt(Math.floor(Math.random() * charset.length)); } return text; } // create random strings that are equal in length to solution return randomString(this.userData.solution.length); } public mutate(entity: Entity) { function replaceAt(str: string, index: number, character: string) { return ( str.substr(0, index) + character + str.substr(index + character.length) ); } // chromosomal drift const replaceIndex = Math.floor(Math.random() * entity.length); return replaceAt( entity, replaceIndex, String.fromCharCode( entity.charCodeAt(replaceIndex) + (Math.floor(Math.random() * 2) ? 1 : -1) ) ); } public crossover(mother: Entity, father: Entity): [Entity, Entity] { // two-point crossover const len = mother.length; let ca = Math.floor(Math.random() * len); let cb = Math.floor(Math.random() * len); if (ca > cb) { const tmp = cb; cb = ca; ca = tmp; } const son = father.substr(0, ca) + mother.substr(ca, cb - ca) + father.substr(cb); const daughter = mother.substr(0, ca) + father.substr(ca, cb - ca) + mother.substr(cb); return [son, daughter]; } public fitness(entity: Entity) { let fitness = 0; for (let entityIndex = 0; entityIndex < entity.length; ++entityIndex) { // increase fitness for each character that matches if (entity[entityIndex] === this.userData.solution[entityIndex]) { fitness += 1; } // award fractions of a point as we get warmer fitness += (127 - Math.abs( entity.charCodeAt(entityIndex) - this.userData.solution.charCodeAt(entityIndex) )) / 50; } return fitness; } public shouldContinue({ population: pop, generation, stats, }: GeneticState<Entity>): boolean { // stop running once we've reached the solution return pop[0].entity !== this.userData.solution; } }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
ClassDeclaration
class CustomPhraseGenetic extends PhraseGenetic { public select1: SingleSelection<Entity> = singleSelection; public select2: PairWiseSelection<Entity> = pairWiseSelection; public notification({ population: pop, generation, isFinished, }: { population: Population<Entity>; generation: number; stats: Stats; isFinished: boolean; }) { if (isFinished) { expect(pop[0].entity).toBe(this.userData.solution); done(); } } }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
TypeAliasDeclaration
type Entity = string;
Glavin001/genetic-js
test/string.spec.ts
TypeScript
TypeAliasDeclaration
type UserData = { solution: string; };
Glavin001/genetic-js
test/string.spec.ts
TypeScript
MethodDeclaration
public seed() { function randomString(len: number) { let text = ""; const charset = "abcdefghijklmnopqrstuvwxyz"; for (let charIndex = 0; charIndex < len; charIndex++) { text += charset.charAt(Math.floor(Math.random() * charset.length)); } return text; } // create random strings that are equal in length to solution return randomString(this.userData.solution.length); }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
MethodDeclaration
public mutate(entity: Entity) { function replaceAt(str: string, index: number, character: string) { return ( str.substr(0, index) + character + str.substr(index + character.length) ); } // chromosomal drift const replaceIndex = Math.floor(Math.random() * entity.length); return replaceAt( entity, replaceIndex, String.fromCharCode( entity.charCodeAt(replaceIndex) + (Math.floor(Math.random() * 2) ? 1 : -1) ) ); }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
MethodDeclaration
public crossover(mother: Entity, father: Entity): [Entity, Entity] { // two-point crossover const len = mother.length; let ca = Math.floor(Math.random() * len); let cb = Math.floor(Math.random() * len); if (ca > cb) { const tmp = cb; cb = ca; ca = tmp; } const son = father.substr(0, ca) + mother.substr(ca, cb - ca) + father.substr(cb); const daughter = mother.substr(0, ca) + father.substr(ca, cb - ca) + mother.substr(cb); return [son, daughter]; }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
MethodDeclaration
public fitness(entity: Entity) { let fitness = 0; for (let entityIndex = 0; entityIndex < entity.length; ++entityIndex) { // increase fitness for each character that matches if (entity[entityIndex] === this.userData.solution[entityIndex]) { fitness += 1; } // award fractions of a point as we get warmer fitness += (127 - Math.abs( entity.charCodeAt(entityIndex) - this.userData.solution.charCodeAt(entityIndex) )) / 50; } return fitness; }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
MethodDeclaration
public shouldContinue({ population: pop, generation, stats, }: GeneticState<Entity>): boolean { // stop running once we've reached the solution return pop[0].entity !== this.userData.solution; }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
MethodDeclaration
public notification({ population: pop, generation, isFinished, }: { population: Population<Entity>; generation: number; stats: Stats; isFinished: boolean; }) { if (isFinished) { expect(pop[0].entity).toBe(this.userData.solution); done(); } }
Glavin001/genetic-js
test/string.spec.ts
TypeScript
ArrowFunction
( environment: Environment, input: DisableSecondFactorInput ) => { return new Promise<DisableSecondFactorMutationResponse>( async (resolve, reject) => { commitMutation<DisableSecondFactorMutation>(environment, { onCompleted: data => { const response = data.disableSecondFactor.secondFactorOrErrors switch (response.__typename) { case "AppSecondFactor": resolve(data) break case "SmsSecondFactor": resolve(data) break case "Errors": reject(response.errors) } }, onError: error => { reject(error) }, mutation: graphql` mutation DisableSecondFactorMutation( $input: DisableSecondFactorInput! ) @raw_response_type { disableSecondFactor(input: $input) { secondFactorOrErrors { ... on AppSecondFactor { __typename } ... on SmsSecondFactor { __typename } ... on Errors { __typename errors { message code } } } } } `, variables: { input, }, }) } ) }
damassi/force-test
src/v2/Components/UserSettings/TwoFactorAuthentication/Components/Mutation/DisableSecondFactor.ts
TypeScript
ArrowFunction
async (resolve, reject) => { commitMutation<DisableSecondFactorMutation>(environment, { onCompleted: data => { const response = data.disableSecondFactor.secondFactorOrErrors switch (response.__typename) { case "AppSecondFactor": resolve(data) break case "SmsSecondFactor": resolve(data) break case "Errors": reject(response.errors) } }, onError: error => { reject(error) }, mutation: graphql` mutation DisableSecondFactorMutation( $input: DisableSecondFactorInput! ) @raw_response_type { disableSecondFactor(input: $input) { secondFactorOrErrors { ... on AppSecondFactor { __typename } ... on SmsSecondFactor { __typename } ... on Errors { __typename errors { message code } } } } } `, variables: { input, }, }) }
damassi/force-test
src/v2/Components/UserSettings/TwoFactorAuthentication/Components/Mutation/DisableSecondFactor.ts
TypeScript
ArrowFunction
data => { const response = data.disableSecondFactor.secondFactorOrErrors switch (response.__typename) { case "AppSecondFactor": resolve(data) break case "SmsSecondFactor": resolve(data) break case "Errors": reject(response.errors) } }
damassi/force-test
src/v2/Components/UserSettings/TwoFactorAuthentication/Components/Mutation/DisableSecondFactor.ts
TypeScript
ArrowFunction
error => { reject(error) }
damassi/force-test
src/v2/Components/UserSettings/TwoFactorAuthentication/Components/Mutation/DisableSecondFactor.ts
TypeScript
ArrowFunction
props => props.menuBoundingBox.height
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
ArrowFunction
props => props.menuBoundingBox.width
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
ArrowFunction
props => props.menuFixed && css` position: fixed; width: ${props.menuBoundingBox.width}px; top: ${props.menuFixedTopOffset}; `
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
ArrowFunction
p => p.active ? 'rgba(53, 50, 50, 0.05)' : 'transparent'
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
ArrowFunction
p => p.active ? 'var(--tina-color-primary)' : 'var(--tina-color-grey-8)'
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
ArrowFunction
props => props.active && css` color: var(--tina-color-primary); fill: var(--tina-color-primary); background-color: rgba(53, 50, 50, 0.05); `
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
ArrowFunction
props => props.disabled && css` pointer-events: none; color: #d1d1d1; fill: #d1d1d1; `
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
ArrowFunction
({ children, open, triggerRef, ...styleProps }) => { const MenuPortal = useMenuPortal() const menuPortalRef = React.useRef<HTMLDivElement | null>(null) const menuOffset = useMemo(() => { if (!triggerRef.current || !menuPortalRef.current) return 0 const menuDropdownBoundingBox = triggerRef.current.getBoundingClientRect() const menuPortalBoundingBox = menuPortalRef.current.getBoundingClientRect() return menuDropdownBoundingBox.x - menuPortalBoundingBox.x }, [triggerRef.current, menuPortalRef.current]) return ( <MenuPortal> <Offset offset={menuOffset}> <div ref={menuPortalRef} {
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
ArrowFunction
() => { if (!triggerRef.current || !menuPortalRef.current) return 0 const menuDropdownBoundingBox = triggerRef.current.getBoundingClientRect() const menuPortalBoundingBox = menuPortalRef.current.getBoundingClientRect() return menuDropdownBoundingBox.x - menuPortalBoundingBox.x }
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
ArrowFunction
props => props.open && css` opacity: 1; pointer-events: all; transform: translate3d(0, 100%, 0) scale3d(1, 1, 1); `
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
ArrowFunction
props => props.offset
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
TypeAliasDeclaration
type MenuPlaceholderProps = { menuBoundingBox: any }
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
TypeAliasDeclaration
type MenuWrapperProps = { menuFixed: boolean menuBoundingBox: any menuFixedTopOffset: string }
blaggacao/tinacms
packages/react-tinacms-editor/src/state/plugins/Menu/MenuComponents.tsx
TypeScript
ArrowFunction
() => { const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor'); assert.deepEqual(color.rgba(), [0.5, 0.5, 0.5, 0.5], 'RGBA array was not set correctly'); assert.strictEqual(color.asString(), 'testColor', 'original text was not set correctly'); assert.strictEqual(color.format(), 'testFormat', 'format was not set correctly'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const color = new Color.Color([-0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor'); assert.deepEqual(color.rgba(), [0, 0.5, 0.5, 0.5], 'RGBA array was not set correctly'); assert.strictEqual(color.asString(), 'testColor', 'original text was not set correctly'); assert.strictEqual(color.format(), 'testFormat', 'format was not set correctly'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const color = new Color.Color([1.1, 0.5, 0.5, 0.5], 'testFormat', 'testColor'); assert.deepEqual(color.rgba(), [1, 0.5, 0.5, 0.5], 'RGBA array was not set correctly'); assert.strictEqual(color.asString(), 'testColor', 'original text was not set correctly'); assert.strictEqual(color.format(), 'testFormat', 'format was not set correctly'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const color = Color.Color.fromHSVA([0.5, 0.5, 0.5, 100]); assert.deepEqual(color.rgba(), [0.25, 0.49999999999999994, 0.5, 1], 'RGBA array was not set correctly'); assert.strictEqual(color.asString(), 'hsl(180 33% 38% / 1)', 'original text was not set correctly'); assert.strictEqual(color.format(), 'hsla', 'format was not set correctly'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor'); const hsva = color.hsva(); assert.deepEqual(hsva, [0, 0, 0.5, 0.5], 'HSVA was not calculated correctly'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const lum = Color.Color.luminance([0.5, 0.5, 0.5, 0.5]); assert.strictEqual(lum, 0.21404114048223255, 'luminance was not calculated correctly'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const lum = Color.Color.luminance([0.03927, 0.03927, 0.03927, 0.5]); assert.strictEqual(lum, 0.003039473684210526, 'luminance was not calculated correctly'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const result = Color.Color.desiredLuminance(0.2, 2, true); assert.strictEqual(result, 0.45, 'luminance was not calculated correctly'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const result = Color.Color.desiredLuminance(0.2, 2, false); assert.strictEqual(result, 0.075, 'luminance was not calculated correctly'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const result = Color.Color.desiredLuminance(0.2, 5, true); assert.strictEqual(result, 0, 'luminance was not calculated correctly'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const color = new Color.Color([0.5, 0.5, 0.5, 0.5], 'testFormat', 'testColor'); const result = color.canonicalHSLA(); assert.deepEqual(result, [0, 0, 50, 0.5], 'canonical HSLA was not calculated correctly'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const firstColor = [1, 0, 0, 1]; const secondColor = [0, 0, 1, 1]; const contrastRatio = Color.Color.calculateContrastRatio(firstColor, secondColor); assert.strictEqual(contrastRatio, 2.148936170212766, 'contrast ratio was not calculated correctly'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const firstColor = [1, 0, 0, 1]; const secondColor = [0, 0, 1, 1]; const result: number[] = []; Color.Color.blendColors(firstColor, secondColor, result); assert.deepEqual(result, [1, 0, 0, 1], 'colors were not blended successfully'); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { assert.deepEqual(Color.Color.parse('#FF00FF')!.rgba(), [1, 0, 1, 1]); assert.deepEqual(Color.Color.parse('#F0F')!.rgba(), [1, 0, 1, 1]); assert.deepEqual(Color.Color.parse('#F0F0')!.rgba(), [1, 0, 1, 0]); assert.deepEqual(Color.Color.parse('#FF00FF00')!.rgba(), [1, 0, 1, 0]); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { assert.deepEqual(Color.Color.parse('red')!.rgba(), [1, 0, 0, 1]); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const colorOne = Color.Color.parse('rgb(255, 255, 0)')!; assert.deepEqual(colorOne.rgba(), [1, 1, 0, 1]); const colorTwo = Color.Color.parse('rgba(0, 255, 255, 0.5)')!; assert.deepEqual(colorTwo.rgba(), [0, 1, 1, 0.5]); const colorThree = Color.Color.parse('rgb(255 255 255)')!; assert.deepEqual(colorThree.rgba(), [1, 1, 1, 1]); const colorFour = Color.Color.parse('rgb(10% 10% 10%)')!; assert.deepEqual(colorFour.rgba(), [0.1, 0.1, 0.1, 1]); const colorFive = Color.Color.parse('rgb(10% 10% 10% / 0.4)')!; assert.deepEqual(colorFive.rgba(), [0.1, 0.1, 0.1, 0.4]); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { const colorOne = Color.Color.parse('hsl(0, 100%, 50%)')!; assert.deepEqual(colorOne.rgba(), [1, 0, 0, 1]); const colorTwo = Color.Color.parse('hsla(0, 100%, 50%, 0.5)')!; assert.deepEqual(colorTwo.rgba(), [1, 0, 0, 0.5]); const colorThree = Color.Color.parse('hsla(50deg 100% 100% / 50%)')!; assert.deepEqual(colorThree.rgba(), [1, 1, 1, 0.5]); const colorFour = Color.Color.parse('hsl(0 100% 50% / 0.5)')!; assert.deepEqual(colorFour.rgba(), [1, 0, 0, 0.5]); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript
ArrowFunction
() => { assert.isNull(Color.Color.parse('#FAFAFA Trailing')); assert.isNull(Color.Color.parse('#FAFAFG')); assert.isNull(Color.Color.parse('gooseberry')); assert.isNull(Color.Color.parse('rgb(10% 10% 10% /)')); assert.isNull(Color.Color.parse('rgb(10% 10% 10% 0.4 40)')); assert.isNull(Color.Color.parse('hsl(0, carrot, 30%)')); assert.isNull(Color.Color.parse('hsl(0)')); assert.isNull(Color.Color.parse('rgb(255)')); assert.isNull(Color.Color.parse('rgba(1 golf 30)')); }
song940/devtools-frontend
test/unittests/front_end/common/Color_test.ts
TypeScript