blob_id large_stringlengths 40 40 | language large_stringclasses 1
value | repo_name large_stringlengths 5 119 | path large_stringlengths 4 271 | score float64 2.52 4.84 | int_score int64 3 5 | text stringlengths 26 4.09M |
|---|---|---|---|---|---|---|
d75d53d4695c3d65166d4a2fb03bbdde0df928b1 | TypeScript | DimitarDKirov/ForumSystemClient | /src/app/models/message.ts | 3.09375 | 3 | export class Message {
text: string;
isError: boolean;
constructor(text: string, isError: boolean = false) {
this.text = text;
this.isError = isError
}
}
|
345ca349d385224034814c3fde1ed62ed0dc6702 | TypeScript | pbehnke/algorithmx | /src/client/utils.ts | 3.140625 | 3 | export interface Lookup<T> { readonly [k: string]: T }
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
export type MapDict<D, M> = { [k in keyof D]: M }
export type Primitive = string | number | boolean
export type RPartial<T> = T extends object ? {
readonly [k in keyof T]?: RPartial<T[k]>
} : ... |
837ee8d7be9798cb0124c5924fbbcb801c7a33f7 | TypeScript | JonaVDM/adventofcode | /2020/day13/index.ts | 2.984375 | 3 | import path from 'path';
import fs from 'fs';
import { performance } from 'perf_hooks';
function getInput() {
const file = fs.readFileSync(path.join(__dirname, 'input'));
return file.toString().trim();
}
function numberWithCommas(x: number) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
c... |
60dd10cc74915355966edad43c62cd74bfd09f93 | TypeScript | mike-works/sql-fundamentals | /test/ex06.create-order.test.ts | 2.796875 | 3 | import { assert } from 'chai';
import { suite, test, timeout } from 'mocha-typescript';
import { createOrder, deleteOrder, getAllOrders } from '../src/data/orders';
import { getDb } from '../src/db/utils';
import './helpers/global-hooks';
export const VALID_ORDER_DATA: Pick<
Order,
| 'employeeid'
| 'customerid... |
94f7618dccded23d47c35053be78ddf957ac8dbd | TypeScript | stephenh/ts-proto | /integration/value/value-test.ts | 2.765625 | 3 | import { Reader } from "protobufjs";
import { ValueMessage } from "./value";
import { ValueMessage as PbValueMessage } from "./pbjs";
describe("values", () => {
it("json value", () => {
const s1 = ValueMessage.fromJSON({
value: "Hello",
anyList: [1, "foo", true],
repeatedAny: [2, "bar", false]... |
0ba70a6cc18cc1fa15437daca0bd9534c8809504 | TypeScript | peterhughesdev/doneyet | /src/store/types.ts | 2.53125 | 3 | import { Timer } from '../util/timer';
export interface ThemeState {
active: string
}
export interface QueueState {
timers: Timer[];
}
const RUNNING = 'RUNNING';
const STOPPED = 'STOPPED';
const PAUSED = 'PAUSED';
export type ScheduleRunningState = typeof RUNNING | typeof STOPPED | typeof PAUSED;
export i... |
b985bc08ea7abdae0656e30aa170e2736e03f8f8 | TypeScript | gustavoam-asdf/algorithm | /devsu-code-jam-preparation/7-toeplitzMatrix.ts | 3.859375 | 4 | interface DiagonalInitial {
value: number
rowPos: number
colPos: number
}
const existInMatrix = (
m: number[][],
rowPos: number,
colPos: number
): boolean => {
if (!m[rowPos]) return false
if (!m[rowPos][colPos]) return false
return true
}
const getDiagonalInitials = (matrix: number[... |
b4d500670b592dc60f8a6d126c295144e0466b90 | TypeScript | tylerlong/ringcentral-typescript | /src/definitions/GlipPostEvent.ts | 2.859375 | 3 | import {GlipMentionsInfo} from '.';
class GlipPostEvent {
/**
* Internal identifier of a post
*/
id?: string;
/**
* Type of a post event
*/
eventType?: 'PostAdded' | 'PostChanged' | 'PostRemoved';
/**
* Internal identifier of a group a post belongs to
*/
groupId?: string;
/**
* Ty... |
e8c76220bbbcac421ed0215fcb1605c1d2214f55 | TypeScript | BitGo/BitGoJS | /modules/sdk-coin-near/src/lib/transferBuilder.ts | 2.578125 | 3 | import { BaseCoin as CoinConfig } from '@bitgo/statics';
import { BaseKey, BuildTransactionError, TransactionType } from '@bitgo/sdk-core';
import { TransactionBuilder } from './transactionBuilder';
import { Transaction } from './transaction';
import * as NearAPI from 'near-api-js';
import assert from 'assert';
import ... |
bf50e4cc4370ca8e9bba9cc0a6894470e7361c0c | TypeScript | spamshaker/lorem-babble | /packages/utils/src/utils.ts | 2.703125 | 3 | import {Dispatch, Reducer, ReducerState, useReducer} from 'react';
export function useReducerWithMiddleware<R extends Reducer<any, any>, I>(
reducer: R,
initializerArg: I & ReducerState<R>,
middleware?: (action: any) => Promise<any>
): [ReducerState<R>, Dispatch<any>] {
const [state, dispatch] = useReducer(red... |
692ccf6a24297a211cb360d264a50a2c029a2bc8 | TypeScript | zhengchaoken/office-ui-fabric | /src/components/FacePile/FacePile.ts | 2.59375 | 3 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE in the project root for license information.
/// <reference path="../Persona/Persona.ts"/>
namespace fabric {
/**
* FacePile
*
* A host for FacePile
*
*/
const PERSONA_CLASS = ".ms-Persona";
const PERSONA... |
c29094041ad6f0a94418c6abd6beaa41922b63a8 | TypeScript | vladdelusive/react-movie-version.2.0 | /src/helpers/overview-editor.ts | 2.546875 | 3 | const random = (min = 150, max = 190) => Math.floor(min + Math.random() * (max - min));
export function overviewEditor(text: string): string {
const newText = text.slice(0, random())
const lastDot = newText.lastIndexOf(".");
return newText.slice(0, lastDot) + "...."
}
|
79c168636b43677b3e603a7889f931f14889ccf6 | TypeScript | ipassynk/angular2-learning | /src/app/list-observable/item.service.ts | 2.734375 | 3 | import {Injectable} from 'angular2/core';
import {Subject} from 'rxjs/Subject';
import {BehaviorSubject} from 'rxjs/Rx';
import {Observable} from 'rxjs/Observable';
export class Item {
constructor(public name:string, public checked:boolean) {
}
}
export interface State {
items: Array<Item>;
}
;
const initItem... |
56c28aa10cddd255f97716486b8e41cdd5489955 | TypeScript | SergioTx/TypescriptCourse | /typescript/app1/app1.ts | 4 | 4 | // string
let myName: string = 'Max';
// myName = 28;
// number
let myAge: number = 27.5;
// myAge = 'Max';
// boolean
let hasHobbies: boolean = false;
// hasHobbies = 1;
// assign types
let myRealAge: number;
myRealAge = 27;
// myRealAge = '27';
// array
let hobbies: any[] = ['Cooking', 'Sports'];
hobbies = [100];... |
f33477b4beae34a8748c95080f19d50e626867be | TypeScript | manucho007/pwa-ferias5 | /src/app/core/firestore.service.ts | 2.828125 | 3 | import { Injectable } from '@angular/core';
import { AngularFirestore, AngularFirestoreDocument, AngularFirestoreCollection} from 'angularfire2/firestore';
import { Observable} from 'rxjs/Observable';
import * as firebase from 'firebase/app';
// The T is a Typescript generic that allows us to use our custom interfaces... |
7069b6ac04fe002c9bb8966f91627e48cd13c602 | TypeScript | NaturalCycles/time-lib | /src/types.ts | 3.140625 | 3 | export type ConfigType = string | number | Date | IDayjs
export type OptionType = { locale?: string; format?: string; utc?: boolean } | string
export type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms'
export type UnitType =
| 'millisecond'
| 'second'
| 'minute'
| 'hour'
| 'day'
| 'month'
| 'y... |
5413348b56b30884b59fa37b927e5efac6291c84 | TypeScript | marcospmail/rocketseat-gobarber-13 | /backend/src/modules/users/repositories/fakes/FakeUsersRepository.ts | 2.71875 | 3 | import { v4 } from 'uuid'
import ICreateUserDTO from '@modules/users/dtos/ICreateUserDTO'
import User from '@modules/users/infra/typeorm/entities/User'
import IUsersRepository from '@modules/users/repositories/IUsersRepository'
import IFindAllProvidersDTO from '@modules/users/dtos/IFindAllProvidersDTO'
class FakeUser... |
49c309a61cf1f4c4ad6459b13694c13be143c928 | TypeScript | KazumasaYasui/riakuto3.1 | /04-typescript/03-function-class/composition.ts | 2.71875 | 3 | import { Rectangle } from "./rectangle";
export class SquareC {
readonly name = 'square';
side: number;
constructor(side: number) {
this.side = side;
}
getArea = () => new Rectangle(this.side, this.side).getArea();
}
|
80b9b8f651cca82567633a3e6600a223222b924b | TypeScript | Vermouth1995/MatchThreeGame | /src/engine/score.ts | 2.703125 | 3 | import PuzzleKeeper from "./puzzle_keeper";
import Goal from "./goal/goal";
import BoardOn from "./board/board_on";
import CoordinateValue from "../concept/coordinate/coordinate_value";
import Coordinate from "../concept/coordinate/coordinate";
import Locus from "../concept/coordinate/locus";
import Font from "../conc... |
169921b9a845cbbe1f4092148d641086e0011361 | TypeScript | Morbden/fluido-nextjs-utils | /src/utils.ts | 2.75 | 3 | import { fetchAPI } from '@fluido/react-utils'
import deepmerge from 'deepmerge'
interface NextStaticPropsReturn {
props: { [key: string]: any }
revalidate?: number
notFound?: boolean
}
interface ComputeFunctionParams {
params?: {
[key: string]: any
}
preview?: boolean
previewData?: any
locale?: s... |
6e6a2dc4f83f94855af6125b9ccbc02d6c22cd99 | TypeScript | sanity-io/sanity | /packages/sanity/src/core/form/__workshop__/_common/data.ts | 2.59375 | 3 | import {Schema} from '@sanity/schema'
import type {Schema as SchemaSchema} from '@sanity/types'
import {keyBy, mapValues} from 'lodash'
import getSimpleDummySchema from './schema/simpleDummySchema'
import getSimpleFieldGroupSchema from './schema/simpleFieldGroupSchema'
export const DUMMY_DOCUMENT_ID = '10053a07-8647-4... |
de03a892f5e6acc9df076ece6fa8f018780f15ff | TypeScript | andhikanugraha/sharades | /src/lib/TopicEncoding.ts | 2.625 | 3 | import { inflate, deflate } from '@progress/pako-esm';
import type { Topic } from './topic';
import { btoaUrl, atobUrl } from './base64url';
const SEPARATOR = '\x1F';
const textEncoder = new TextEncoder();
const textDecoder = new TextDecoder('utf-8');
export async function deflateTopicWords(words: string[]): Promise... |
9e7bbfad5e6d0d5a1ccd053c120be5a1da873096 | TypeScript | HaifengDu/ts-ds-tool | /src/heap/__test__/Heap.test.ts | 3.78125 | 4 | import { MaxHeap } from "../MaxHeap";
import { MinHeap } from "../MinHeap";
describe("MaxHeap test", () => {
test("should create an empty max heap", () => {
const maxHeap = new MaxHeap<number>();
expect(maxHeap).toBeDefined();
expect(maxHeap.peek()).toBeNull();
expect(maxHeap.isEmpt... |
c0d04f1389f81fe9e9c4bec944fa674631b69ad3 | TypeScript | Daria0109/Todolist_ReactTS | /src/features/Login/auth-reducer.test.ts | 2.703125 | 3 | import {AuthStateType, authReducer, setIsLoggedIn, setLogin} from './auth-reducer';
let startState: AuthStateType;
beforeEach(() => {
startState = {
isLoggedIn: false,
login: null
}
})
test('loggedIn status should be set to the state', () => {
const endState = authReducer(startState, setIsLoggedIn({isL... |
6457e5781649329f137c09ae4ea55f97bf47d498 | TypeScript | VincentVen/Framing | /src2/modules/games/dzpk/newGameScene/caiSanZhangWindow/CaiSanZhangBuyItem.ts | 2.53125 | 3 | /**
* 猜三张购买列表item
* @author none
*/
class CaiSanZhangBuyItem extends how.module.ItemView {
public title: eui.Label;
public odds: eui.Label;
public multipleBtn1: how.CheckBox;
public multipleBtn5: how.CheckBox;
public multipleBtn10: how.CheckBox;
public constructor() {
super();
... |
1a735743d9d00b06a5e531101d5cd001f18b127e | TypeScript | AdanGaitan/ProyectoPracticaAngular | /src/app/directiva/directiva.component.ts | 2.59375 | 3 | import { Component, OnInit } from '@angular/core';
interface Producto{
nombre:string;
stock:number;
fabricante:string;
fechaVence:Date;
esImportante:boolean;
}
@Component({
selector: 'app-directiva',
templateUrl: './directiva.component.html',
styleUrls: ['./directiva.component.scss']
})
export class ... |
c41b30387aea8ea007e2c3850b72ddf900ae22ab | TypeScript | bravc/myfavoritepart | /src/config/passport.ts | 2.546875 | 3 | import passport from 'passport';
const LocalStrategy = require('passport-local').Strategy;
import * as bcrypt from 'bcrypt-nodejs';
import { User } from '../models/User';
import { Request } from 'express';
export let local = passport.use('local',
new LocalStrategy({passReqToCallback : true}, async (req: Request, us... |
f0a2acd8a1f91644ea0a6adfdf84f4639a161a6a | TypeScript | tusharmath/qio | /packages/benchmarks/Stream/Stream.ts | 2.671875 | 3 | /**
* Created by tushar on 09/09/19
*/
import {QIO} from '@qio/core'
import {Suite} from 'benchmark'
import {PrintLn} from '../internals/PrintLn'
import {qioRuntime} from '../internals/RunSuite'
const suite = new Suite('QStream')
const count = 1e6
const arr = new Array<number>()
for (let i = 0; i < count; i++) {... |
dbadfc7e6c496ba718179c0c0f21ee00d5e52d74 | TypeScript | kyeah/undercov | /src/storageObject.ts | 2.96875 | 3 | /**
* Configurable options for each repo.
*/
export type Repo = {
repoName: string,
branchUrlTemplate: string,
prUrlTemplate: string,
pathPrefix: string,
authUrlTemplate: string
}
/**
* Value object to encapsulate options.
*/
export interface IStorageObject {
overlayEnabled: boolean
debugEnabled: boo... |
006fa70f245b867632fa0985d29be7f8d7625cd0 | TypeScript | atayahmet/cs-algorithms | /queue/src/index.ts | 2.65625 | 3 | import Queue from './queue';
const queue = new Queue;
console.log(queue.isEmpty());
queue.add(1);
queue.add(2);
queue.add(3);
console.log(queue.peek());
console.log('remove->', queue.remove());
console.log(queue.peek());
console.log('remove->', queue.remove());
console.log(queue.peek());
console.log('remove->', q... |
95821c73d4024893961dc29bcdda331ce04e3085 | TypeScript | amazinglynormal/forex-dashboard | /src/utils/calculateOneYearAgo.ts | 2.578125 | 3 | export const calculateOneYearAgo = () => {
const today = new Date();
const date = today.getDate();
const month = today.getMonth() + 1;
const year = today.getFullYear() - 1;
return `${year}-${month < 10 ? "0" : ""}${month}-${
date < 10 ? "0" : ""
}${date}..`;
};
|
cb72e60a27f4dd07966ce5aa5950f2d624d11836 | TypeScript | gabrielgouv/rockr | /packages/rockr-core/src/utils/string-utils.ts | 2.71875 | 3 | import * as _ from 'lodash'
export const parseToKebabCase = (text: string): string => {
return _.kebabCase(text)
}
export const parseToSnakeCase = (text: string): string => {
return _.snakeCase(text)
}
export const generateIdByName = (text: string): string => {
return _.uniqueId(_.snakeCase(text) + '_')... |
e0c6c1bc490fc5bb0250eadc550df74fe57dda80 | TypeScript | lmeijvogel/my_node_openzwave | /ZWaveValueChangeListener.ts | 2.59375 | 3 | import { Configuration } from "./Configuration";
import { Logger } from "./Logger";
import { Node } from "./Node";
import { MyZWave } from "./MyZWave";
export class ZWaveValueChangeListener {
switchPressed: (node: Node, sceneId: number) => void = (_node, _sceneId) => {};
constructor(private readonly myZWave:... |
6410d9f9714b7f5c0946ef8828a0aec90fe6dd28 | TypeScript | aesthetic-suite/framework | /packages/utils/src/toArray.ts | 3.078125 | 3 | export function toArray<T>(value: T | T[]): T[] {
if (value === undefined) {
return [];
}
return Array.isArray(value) ? value : [value];
}
|
68f7973f5e36d345c65236fcd3c1e9b6ececf95f | TypeScript | sk13/MyCalliopeSymCryptoExtension | /main.ts | 2.875 | 3 | /**
* Functionallity to do symmetric encryption / decryption.
*
*
*/
//% weight=2 color=#f2c10d icon="\uf21b"
//% advanced=true
//% groups=['1 Encryption','2 Communication',]
namespace Crypto {
class KeyValue {
key: number;
value: string;
}
class KeyValueStore {
m_Store: Arr... |
987fbad614f4a151583d1d892537dcd6cc82954d | TypeScript | emilybache/SupermarketReceipt-Refactoring-Kata | /typescript/src/model/ProductQuantity.ts | 2.578125 | 3 | import {Product} from "./Product"
export class ProductQuantity {
constructor(public readonly product: Product,
public readonly quantity: number) {
this.product = product;
this.quantity = quantity;
}
}
|
2d450bccf9de0e8116212fa1a7caddddb4aea1b1 | TypeScript | makeevvd/Table | /my-app/src/hooks/useChildrenSort.ts | 2.59375 | 3 | import {DataInterface, DataInterfaceWithChildren} from "../components/Table/Table";
import {useMemo} from "react";
export const useChildrenSort = (tableData: DataInterface[]): DataInterfaceWithChildren[] => {
const parentElements = tableData.filter((dataElement) => dataElement.parentId === 0);
const parentsWithChi... |
baed1519c7ca5ea7da723cae74f120297d322b27 | TypeScript | saffi-codefresh/datadog-api-client-typescript | /packages/datadog-api-client-v2/models/IncidentFieldAttributesMultipleValue.ts | 2.640625 | 3 | /**
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2020-Present Datadog, Inc.
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-ge... |
7c963352725e36713222d1348fb7a45a0fdb7b17 | TypeScript | softwaresauna/ts-template | /src/hello.ts | 3.015625 | 3 | export class Person {
constructor(public readonly name: string) {}
}
export function hello(person: Person): string {
return `Hello, ${person.name}!`;
}
|
e14d96169f27cd463060a99d351d56d61be4af6b | TypeScript | haimich/copyundpasta | /test/utils/CategoryUtilTest.ts | 2.65625 | 3 | import CategoryUtil from "@/utils/CategoryUtil";
describe("getAllArticleCategories", () => {
test("should return parent and child categories", () => {
let categories = CategoryUtil.getAllArticleCategories();
// console.log(categories);
});
});
describe("getAllRecipeCategories", () => {
test("should ret... |
ca39cfd9b951882f29e3cbd38b705dc020902ff5 | TypeScript | viniciusstroher/app-delivery-poc | /src/domain/common/IValueObject.ts | 2.796875 | 3 | export interface IValueObject{
equals(compareEntity: IValueObject):boolean;
} |
456cb7ebffa79e1d829bc9a1a5ec5867caf4c339 | TypeScript | Tidyzq/Blog-Front-Console | /src/utils/redux.ts | 2.703125 | 3 | import { Action, Reducer } from 'redux'
import { ThunkAction } from 'redux-thunk'
export const handleActions = <S>(reducerMap: { [type: string]: Reducer<S, any> }, defaultState: S): Reducer<S> => (prevState, action) => {
const state = prevState || defaultState
const actionType = action.type
if (actionType && red... |
12976e5d7853ec16844d50008e14694c86169028 | TypeScript | Akachu/five-gigabyte-of-free-storage | /src/modules/fileManager/reducer.ts | 2.671875 | 3 | import { createReducer } from 'typesafe-actions';
import { FileManagerAction } from './types';
import { FileManagerState } from './interface';
import {
REQUEST_FILE_UPLOAD,
REQUEST_FILE_DOWNLOAD,
COMPLETE_FILE_REQUEST,
} from './actions';
const initialState: FileManagerState = {
requests: [],
};
const fileMan... |
0ccd5dbf001bae980fe62113e63bb7e7a4141e53 | TypeScript | cyrt63/demos | /JSXGraph/conic.ts | 2.515625 | 3 | var graph = JXG.JSXGraph;
var popUp: Window = open("", "", "width=800, height=600");
var css = '<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />';
popUp.document.documentElement.innerHTML = css+'<div id="box" class="jxgbox" style="width:800px; height:600px;"></div>... |
317a9ab2125d3ccb0fd6a484beb4e48ca514e033 | TypeScript | edgars1337/nim-js | /src/nim/node.ts | 3.234375 | 3 | import {isEqual} from 'lodash-es';
export class Node {
// TODO - fix accesses
public piles: number[] = [];
public heuristicValue: number = 0;
public childList: Node[] = [];
constructor(piles: number[], parent: Node | null = null) {
if (parent === null) {
this.piles = piles;
... |
ab4ad5e3c997d8542f9aab8a0341ddc0c9232542 | TypeScript | grok88/gato | /src/app/reducers/auth-reducer.ts | 2.671875 | 3 | const initialState = {};
type AuthStateType = typeof initialState;
export const authReducer = (state: AuthStateType = initialState, action: ActionsType): AuthStateType => {
return state
}
type ActionsType = any; |
3176a00e99eb0d6b49d7ed777f7255a851744ef1 | TypeScript | PRossetti/wp-typescript-expressjs-api | /src/routes/artist/releaseData/releaseData.controller.ts | 2.59375 | 3 | import { Request, Response, NextFunction } from 'express';
import AritstReleaseDataService, { queryMany } from '@services/ArtistReleaseData.service';
class ArtistReleaseDataController {
static async get(req: Request, res: Response, next: NextFunction): Promise<void> {
try {
const {
params: { id, na... |
3115eb8d8a37ae7612aa8c4125d07df9390c629e | TypeScript | arturdedela/patterns-lab2 | /src/commands/ChangeBorderWidthCommand.ts | 2.53125 | 3 | import { Command } from "./abstract/Command";
import { IShapeEditor } from "../Editor/Editor";
export class ChangeBorderWidthCommand extends Command {
private readonly width: number;
constructor(editor: IShapeEditor, width: number) {
super(editor);
this.width = width;
}
execute(): void {
this.sav... |
6708a5bb15ffe01dc692f7c4a039d6d1248ab8b4 | TypeScript | udacity-jhon/serveless-typescript | /src/functions/auth/rs256Auth0Authorizer/handler.ts | 2.59375 | 3 | import { CustomAuthorizerEvent, CustomAuthorizerResult } from 'aws-lambda'
import 'source-map-support/register';
import {JwtToken} from "../aut0Authorizer/JwtToken";
import {verify} from 'jsonwebtoken';
const cert = `-----BEGIN CERTIFICATE-----
MIIDDTCCAfWgAwIBAgIJRDj/IhBbmmVAMA0GCSqGSIb3DQEBCwUAMCQxIjAgBgNV
BAMTGWRld... |
ccaa9874c526422fd895949b50de2ab218823937 | TypeScript | risen619/swapi | /src/app/store/effects/character.effects.ts | 2.578125 | 3 | import { Injectable } from '@angular/core';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Action } from '@ngrx/store';
import { Observable, of } from 'rxjs';
import { mergeMap, catchError, switchMap } from 'rxjs/operators';
import * as CActions from '../actions/character.actions';
import * as FAc... |
624dc7bc42059d461cb1af39af0b510543cf966c | TypeScript | TiE23/somethingjunk | /typescript/quizzes/src/tictactoe/__tests__/index.test.ts | 3.421875 | 3 | import { Game } from "../index";
describe("Tic-Tac-Toe Game", () => {
it("should work correctly", () => {
expect(true).toBe(true);
});
describe("given a full board with X as the winner", () => {
const game = new Game();
game.makeMove({ player: "X", coord: [0, 0] });
game.makeMove({ player: "O",... |
37c3cf4ed1c98b8b473b728cefc9d51247043fbf | TypeScript | EslavaDev/bingo-unique-co | /backend/functions/src/helpers/functions-helpers.ts | 2.671875 | 3 | import { limits } from "./dictionary";
export const randomValueBoard = (label: string) => {
const {min, max} = limits(label);
return Math.floor(Math.random() * ((max+1) - min)) + min;
}
export const randomValueGame = () => {
return Math.floor(Math.random() * ((75+1) - 1)) + 1;
} |
48837edadc923e068b682648a64b61bb4a898408 | TypeScript | Roman1137/saas-template-automation | /framework/dataProvider/name.ts | 3.21875 | 3 | import {String} from "../helperTypes";
import {RandomDataGenerator} from "./randomDataGenerator";
export class Name {
public static LengthMax(): number {
return 1024;
}
public static LengthMin(): number {
return 3;
}
public static Empty(): string {
return String.Empty;
... |
496a73e8a3f6129ce548a5acb94cf1dc0af47309 | TypeScript | aszecsei/electric-irc | /app/renderer/reducers/view-channel.ts | 2.796875 | 3 | import { ElectricState } from '../store'
import { IViewChannelAction } from '../actions'
export default function sendMessage(
state: ElectricState,
action: IViewChannelAction
): ElectricState {
let newState = state
newState = newState.set('currentConnectionId', undefined)
newState = newState.set('currentChan... |
8554594c56c3d6745c9be1f54cf1cc6880e10dde | TypeScript | jhonpedro/github-clone | /server/src/controllers/RepositoryStarsController.ts | 2.75 | 3 | import { Request, Response } from 'express'
import slugify from 'slugify'
import Repository from '../models/Repository.model'
import RepositoryStars from '../models/RepositoryStars.model'
import User from '../models/User.model'
import AppError from '../utils/errors/AppError'
export default {
async star(req: Request,... |
a97d4a5c332bdf216e38a4b0404e5b7c5af7f523 | TypeScript | rawagner/console | /frontend/packages/git-service/src/utils/build-tool-detector.ts | 2.859375 | 3 | import { BuildTool, BuildTools, BuildType } from '../types';
export function detectBuildType(files: string[]): BuildType[] {
const buildTypes = BuildTools.map((t: BuildTool) => {
const matchedFiles = files.filter((f: string) => t.expectedRegexps.test(f));
return { buildType: t.type, language: t.language, fil... |
5bdd105c44cf469affac100f74e61ac20fa2daeb | TypeScript | aubert-creation/tmdb-api | /src/models/Genre.ts | 2.890625 | 3 | export class Genre {
id!: string
name!: string
constructor(init: Genre) {
Object.assign(this, init)
}
}
|
ea9c35511b5e924d825c78ab6a1891d65672a0f9 | TypeScript | tolley/shop | /shopfront/src/actions/CartActions.ts | 3.265625 | 3 | import { Product } from '../types';
export interface CartState {
items: Array<Product>,
totalPrice: number,
showSummary?: boolean
};
export interface CartData {
items: Array<Product>
};
export type CartAction =
{ type: 'CART_ADD', payload: CartData } |
{ type: 'CART_REMOVE', payload: number }... |
d3fa3d9ccb22b53eb693f5b2a81e4f86607da2b0 | TypeScript | SWDV-665/final-project-dking74 | /server/src/exceptions/ServerErrorResponse.ts | 2.71875 | 3 | import BaseErrorResponse from './BaseErrorResponse';
export default class ServerErrorResponse extends BaseErrorResponse {
constructor(errorMessage?: string) {
super(
'An internal server occurred. ' +
`Original Error: ${errorMessage ? errorMessage : ''}`,
500
);
}
} |
2fb45df83949e7a9bd298a1d52637ec7b9a28a9c | TypeScript | adanfm/estudos-ts | /server/app/errorHandlerApp.ts | 2.546875 | 3 | import { Request, Response, ErrorRequestHandler, NextFunction } from 'express'
export function errorHandlerApp(err: ErrorRequestHandler, req: Request, res: Response, next: NextFunction) {
console.error(`APP error handler foi executado: ${err}`);
res.status(500).json({
errorCode: 'ERR-001',
message: 'Inter... |
7f05049ba061762ae0b89a059fec8f0109181df3 | TypeScript | mesfinmetekia/Angular-Login-Page | /src/app/dashboard/dashboard.component.ts | 2.515625 | 3 | import { Component, OnInit, Output } from '@angular/core';
import { User } from "../user";
import { FormGroup, FormControl, Validators } from '@angular/forms';
import * as EventEmitter from 'events';
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.comp... |
14ccabb735e10262bfd281a01d952cd73eb6dd5d | TypeScript | JarLob/imodeljs | /core/quantity/test/Parsing.test.ts | 2.671875 | 3 | /*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------... |
cba8b50d1933ef0691da001022858388940175dc | TypeScript | Artezio/SURVEYBUILDER | /packages/models/src/factories/itemFactory.ts | 2.546875 | 3 | import TextItem from "../models/questionItems/textItem";
import BooleanItem from "../models/questionItems/booleanItem";
import Item from "../models/item";
import GroupItem from "../models/groupItem";
import IItemCollection from "../interfaces/IItemCollection";
import StringItem from "../models/questionItems/stringItem"... |
fc8e49dc22eae6c4301f1b5a812445a2e021d568 | TypeScript | Rasukarusan/express-mongodb-react-app | /api/src/services/orderService.ts | 2.6875 | 3 | import Order from '../models/orders';
let faker = require("faker/locale/ja")
export default class OrderService {
public async getAll() {
try {
return Order.find().exec();
}catch(err) {
throw err;
}
}
public async getById(id: string) {
try {
return Order.findById(id).exec();
... |
da96c3c52faae241b83728f9115d4308b1e95cc9 | TypeScript | kentotakeuchi/data-structures-and-algorithms | /leetcode/easy/can-place-flowers.ts | 3.65625 | 4 | // https://leetcode.com/problems/can-place-flowers/
// MINE..
/*
function canPlaceFlowers(flowerbed: number[], n: number): boolean {
let newFlowers = 0;
const empties = flowerbed.join('').split('1'); // ['', '000', '']
console.log({empties})
for(let i=0; i<empties.length; ++i) {
// edge
... |
ddb9942fb251c339cdaa2fa14f6f98c3b9138eab | TypeScript | sunseekker1/cas-fee | /abend-06-27/uebung Modularisierung/Loesung/binder.ts | 2.78125 | 3 | export class Binder{
bind(data : any) : void {
// would bind the view to the controller
console.log('Data bound: ' + data);
}
} |
ee75f9bd662c62614eccd8473ab441b8d15684ea | TypeScript | alexey-kozlenkov/ng-movies-demo | /src/app/page-movie-list/movie-card/country-flag.pipe.ts | 2.546875 | 3 | import { Pipe, PipeTransform } from '@angular/core';
const languageCodeToFlag = {
'en': '🇺🇸',
'it': '🇮🇹',
'lt': '🇱🇹',
};
@Pipe({
name: 'languageToFlag'
})
export class LanguageToFlagPipe implements PipeTransform {
transform(code: string): string {
return languageCodeToFlag[code] || '🤷♀️';
}
}
|
e370ebc28ef5f5328db08d12616d49090a1b290a | TypeScript | 9andresc/typescript-deep-dive | /3-future-javascript/sample-18.ts | 3.640625 | 4 | // `const`
const foo; // Error: `const` declarations must be initialized
const foo = 123;
foo = 456; // Error: Cannot redeclare block-scoped variable `foo`
const foo = 123;
if (true) {
const foo = 456; // Allowed as it's a new variable limited to this `if` block
}
const foo = { bar: 123 };
foo.bar = 456;
console.... |
2c1698ae683cf00d380e74ea8ac87021c9444f3b | TypeScript | krawaller/algol5 | /modules/ui/src/helpers/useDemo.ts | 2.609375 | 3 | import { useState, useEffect, useRef } from "react";
import { AlgolDemo, AlgolHydratedDemo, AlgolDemoPatch } from "../../../types";
import { hydrateDemoFrame, emptyDemo, hydrateDemoBase } from "../../../common";
import { GameId } from "../../../games/dist/list";
const FRAME_LENGTH_MS = 1500;
const WIN_FRAME_FACTOR = 5... |
4d6ff0b4df59c3fa5e6ffc1c9a4fed6da98566b6 | TypeScript | zachhardesty7/semantic-styled-ui | /src/components/IconLink/IconLinkGroup.d.ts | 2.609375 | 3 | import * as React from "react"
import { JustifyProp, PaddedVerticalProp } from "../../types"
export type IconLinkGroupPadding =
| "compact"
| "tight"
| "base"
| "relaxed"
| "loose"
export interface IconLinkGroupProps {
/**
* flex alignment of icon container
*/
justify?: JustifyProp
/**
* spac... |
c0d7aeaed8c34b9e0ee3bfea3af4fec68fb83163 | TypeScript | SimoesFO/vaibem | /server/src/app/validations/authenticationValidate.ts | 2.703125 | 3 | import * as Yup from 'yup';
const authSchema = Yup.object().shape({
email: Yup.string()
.email('E-mail inválido')
.required('O campo E-mail é obrigátorio'),
password: Yup.string()
.min(5, 'A senha deve ter entre 5 e 20 caracteres.')
.max(20, 'A senha deve ter entre 5 e 20 caracteres.')
.require... |
995f0813689ca6498b3eac2cf2273e2b75242a32 | TypeScript | keymanapp/s.keyman.com | /kmw/engine/17.0.97/src/engine/main/text/prediction/modelManager.ts | 2.6875 | 3 | // Defines the KeyboardManager and its related types.
///<reference path="../../keyboards/kmwkeyboards.ts" />
namespace com.keyman.text.prediction {
export class ModelManager {
// Tracks registered models by ID.
private registeredModels: {[id: string]: ModelSpec} = {};
// Allows for easy model lookup by... |
66a501d1885bb72b3b0c1d9d94c39b225f2a03e3 | TypeScript | ehog90/aggrid-test | /src/app/mappers.ts | 2.59375 | 3 | import {IStatEntry, IStroke, ITenminStat, ITenminStatEntry, ITimeAndCountry} from './interfaces';
import {getCountryName} from "./country-resolver";
/**
* Created by ehog on 2017. 04. 14..
*/
export function mapTenminStat(data: any[]): ITenminStat {
return {
timeStart: new Date(data[0]),
all: data[1],
... |
3d71dd44519dc29e543021d88482d8f1123a4ec4 | TypeScript | hapinessjs/hapiness | /src/extensions/http-server/enums.ts | 2.640625 | 3 | export enum LifecycleHooksEnum {
OnPreAuth = <any>'onPreAuth',
OnPostAuth = <any>'onPostAuth',
OnPreHandler = <any>'onPreHandler',
OnPostHandler = <any>'onPostHandler',
OnPreResponse = <any>'onPreResponse'
}
export enum LifecycleEventsEnum {
OnPreAuth = <any>'onPreAuth',
OnPostAuth = <any>'... |
7caf57acdbe723cc8cbf5ff6091261b165e4aa6d | TypeScript | cpsoneghett/typescript_e2e_automation_tutorial | /tests/e2e/ts/specs/cenario02.spec.ts | 2.765625 | 3 | import { InicioPage } from "../pages/inicio.page";
import { Reports } from "../components/reports.component";
describe('Teste cenário 02 - Funcionalidades gerais', () => {
var Inicio: InicioPage = new InicioPage(); //Declaramos uma instância da nossa página aqui!
afterEach(function () {
Reports.tiraP... |
13ca8fe63eccbe7ccf4d278ef7182159c1eb2c20 | TypeScript | marcprux/setup-swift | /src/get-version.ts | 2.5625 | 3 | import { exec } from "@actions/exec";
export async function getVersion(
command: string = "swift",
args: string[] = ["--version"]
) {
let output = "";
let error = "";
const options = {
listeners: {
stdout: (data: Buffer) => {
output += data.toString();
},
stderr: (data: Buffer)... |
44d6b69654c8dd8e902af5817dee1b2b05689c43 | TypeScript | vdmchpg/TZ-1 | /source/api/index.ts | 2.78125 | 3 | import { NewsBlock } from '../state/modules/news';
const API_KEY = '8ce44c3a6df140b3a6b01bd6f0c29392';
const API_URL = 'https://newsapi.org/v2/top-headlines';
const timeout = (delay: number): () => Promise<{}> => () => new Promise(resolve => setTimeout(resolve, delay));
export type API = {
checkToken: () => LoginR... |
5411e114ab29beb9803fcf4ee4a6c9681a432313 | TypeScript | paullessing/natasha-smart-home | /src/server/appliances/appliance.converter.ts | 2.703125 | 3 | import {Component} from '../../util';
import {Appliance} from '../../shared/appliance.interface';
import {Device} from '../devices/device.interface';
@Component()
export class ApplianceConverter {
public convertDevice(device: Device): Appliance[] {
const baseAppliance: Appliance = {
id: device.id,
n... |
86e988a10dcc0aee6cbf09ea38174a1403221499 | TypeScript | donascimentomarcelo/finansys-angular | /src/app/in-memory-database.ts | 2.53125 | 3 | import { InMemoryDbService } from 'angular-in-memory-web-api';
import { Category } from './pages/categories/shared/Category';
import { Entry } from './pages/entries/shared/entry.model';
export class InMemoryDatabase implements InMemoryDbService {
createDb() {
const categories: Category[] = [
{... |
83d8173b48ca9f588dc1e753b02b0fe5476d27a8 | TypeScript | FiberJW/design-starter-kit | /styles/typography.ts | 2.859375 | 3 | export function rem(multiple: number) {
return multiple * 16;
}
export function lineHeight(fontSize: number, multiple: number = 1.2) {
return fontSize * multiple;
}
export type fontSize = number;
export type typeScale = (note: number) => fontSize;
export function genTypeScale(ratio: number): typeScale {
return... |
011d69cfdf66989ad83a710b2fe1928510b1ac07 | TypeScript | tanle-bmd/050-shipping-backend-2.0 | /src/services/StaffService.ts | 2.65625 | 3 | import { Service } from "@tsed/common";
import { CoreService } from "../core/services/CoreService";
import { Staff } from "../entity/Staff";
import { validatePassword } from "../util/passwordHelper";
import { Permission } from '../entity/Permission';
import { Exception } from "ts-httpexceptions";
@Service()
export c... |
b909c72280733d347a8c8932d7b249dab790cdfa | TypeScript | scalvert/ember-cli-checkup | /src/results/project-info-task-result.ts | 2.703125 | 3 | import { ITaskResult, IConsoleWriter } from '../types';
export default class ProjectInfoTaskResult implements ITaskResult {
type!: string;
name!: string;
version!: string;
toConsole(writer: IConsoleWriter) {
writer.heading('Project Information');
writer.column({
Name: this.name,
Type: this... |
bb3cd8c1200806dac3230a47970a1769f3db2bf6 | TypeScript | LedgerHQ/ledger-live-common | /src/families/solana/bridge/mock.ts | 2.640625 | 3 | import { flow, isArray, isEqual, isObject } from "lodash/fp";
import { isUndefined, mapValues, omitBy } from "lodash/fp";
import { cached, ChainAPI, Config, getChainAPI, logged, queued } from "../api";
import { makeBridges } from "./bridge";
import { makeLRUCache } from "../../../cache";
import { getMockedMethods } fro... |
965d5ce6274566d5148ce59c305fa4ff173b818d | TypeScript | yujuiting/jtable | /packages/core/src/types/context.ts | 2.828125 | 3 | /**
* @packageDocumentation
* @module core/context
*/
import { AnyAction } from './action';
export interface Store<T = unknown> {
sourceData: T[];
visibleData: T[];
pageCurrent: number;
pageTotal: number;
pageSize: number;
sortKey: string;
sortOrder: 'asc' | 'desc';
columns: ColumnInfo<T>[];
}
expo... |
11995b872165b5ca7a4e14a3729781cd1b42b351 | TypeScript | sarker24/eesmiley-fromtend | /service-foodwaste/app/src/services/guest-registrations/hooks/validate-guest-registration.ts | 2.5625 | 3 | /**
* Validate for 2 conditions:
* If user has given guest type id, validates the record exists and is active.
* If user has guest types enabled, validates the registration has guest type id
*
* Before hook: CREATE / PATCH
*/
import * as errors from '@feathersjs/errors';
import { Hook, HookContext } from '@feath... |
1853c2205b6b58d8cccbbbe35b380340dea961fe | TypeScript | FabianGosebrink/real-time-cross-platform-aspnetcore-angular-signalr | /client/src/app/food/validators/isInRange.validator.ts | 2.625 | 3 | import { Attribute, Directive, forwardRef } from '@angular/core';
import {
FormControl,
NG_VALIDATORS,
ValidationErrors,
Validator,
} from '@angular/forms';
const INT_MAX = 2147483647;
@Directive({
selector:
'[app-isInRange][formControlName],[app-isInRange][formControl],[app-isInRange][ngModel]',
prov... |
aa822e69300db188d812b5c0579a6614883d3562 | TypeScript | jguyon/check | /test/oneOf.test.ts | 3.125 | 3 | import * as check from "../src";
test("check succeeds when at least one child check succeeds", () => {
const checkValue = check.oneOf(
check.number(),
check.chain(check.string(), check.toLower()),
check.chain(check.string(), check.toUpper()),
);
const result = checkValue("Jerome");
expect(result).... |
b752506a987c2fbb4fd694d15ff4725961992bf4 | TypeScript | akira345/gitbeaker | /packages/gitbeaker-requester-utils/src/RequesterUtils.ts | 2.6875 | 3 | import FormData from 'form-data';
import { decamelizeKeys } from 'xcase';
import { Agent } from 'https';
import { stringify } from 'query-string';
export interface RequesterType {
get(service: object, endpoint: string, options?: object): Promise<any>;
post(service: object, endpoint: string, options?: object): Prom... |
007629feeb3b639b34c4fcbdf6301e682fff9e77 | TypeScript | ZhangMYihua/angular-ssr | /source/transpile/transpile.ts | 2.65625 | 3 | import {ScriptTarget} from 'typescript';
import {transform} from 'babel-core';
import {TranspileException} from 'exception';
export type TranspileResult<R> = {
load(): R;
}
const transpiled = new Map<string, TranspileResult<any>>();
const cache = {
read<T>(moduleId: string, factory?: () => TranspileResult<T>):... |
ebe8ae2f8a1884c682d28317d341a8e11c57b4f1 | TypeScript | mcnguyen/type-plus | /src/function/AnyFunction.spec.ts | 3.09375 | 3 | import { AnyFunction, assertType } from '..'
test('basic', () => {
const foo: AnyFunction = x => x
foo()
const result = foo(false)
// only any can be boolean here
assertType.isBoolean(result)
})
test('define param as tuple', () =>{
const foo: AnyFunction<[number,string]> = x => x
foo(1, 'a')
})
test(... |
673023cc04e91b7b13a6aa209729a0af99fbeeab | TypeScript | chiqui3d/stencil-head | /src/helper/style.ts | 3.15625 | 3 | export default class Style{
private document: Document = document;
/**
* Create and render in the dom the style tags
*/
public create(styles): void {
this.setStyles(styles)
}
/**
* Return the style tags in HTML|String format, so you can manipulate.
* Note: this does not add it to the Dom.... |
fc4d612f170a3ac162102201edd7b6064a947668 | TypeScript | adam-saland/layouts-service | /src/provider/config/ConfigUtil.ts | 3.25 | 3 | import {ApplicationScope, RegEx, Rule, Scope, WindowScope} from '../../../gen/provider/config/layouts-config';
/**
* Defines the relative precedence of each available scope. The names of the constants match the `Scopes` type (and it
* is important that all scopes are included in the enum). Because of this alignment,... |
7e4bb1aec47318b0bdfcd9ab4b98118261e3abbc | TypeScript | nrfm/umbrella | /packages/rasterize/src/shader.ts | 2.890625 | 3 | import type { IGrid2D, TypedArray } from "@thi.ng/api";
import type { IRandom } from "@thi.ng/random";
import { SYSTEM } from "@thi.ng/random/system";
import type { Shader2D } from "./api.js";
export const defPattern = <T extends any[] | TypedArray, P>(
pattern: IGrid2D<T, P>
): Shader2D<P> => {
const [w, h] =... |
ff68921c6f5ab09f094cdab388253e06e3d45bd7 | TypeScript | Marcos240/common-2scool | /@helper/network/HttpQuere.ts | 2.90625 | 3 | export default class HttpQueue {
private requesting: boolean;
private stack: Array<{
input: any;
resolve: any;
reject: any;
}>;
private queryFunction: Function;
constructor (queryFunction: Function) {
this.requesting = false;
this.stack = [];
this.queryFunction = queryFunction;
}
... |
0b2dd94e3e3d041d701d387397869f6c5a203e30 | TypeScript | yhaskell/af-filtering-matches | /backend/src/routes/matches.ts | 2.78125 | 3 | import { RequestHandler } from 'express'
import { Types } from 'mongoose'
import { default as People, Person } from '../db/person'
import { validateFilter, setFilters, setDistanceFilter } from '../filter'
import * as response from './response'
import * as log from '../lib/logger'
/**
* Returns all matches that are ... |
d3d61a2cd1baf4e8f1e564e5e4eeb5803d68f13a | TypeScript | ravensinth/retro | /frontend/src/utils/user.utils.ts | 2.828125 | 3 | import { removeFirstOccurenceFromArray } from ".";
export const ROLE_MODERATOR = "moderator";
export const ROLE_PARTICIPANT = "participant";
export function getUser(boardId: string) {
const userObject = localStorage.getItem(boardId);
if (userObject !== null) {
return JSON.parse(userObject);
}
return null;... |
7c9a92efe30957ba718ed2a95c50f110f926c596 | TypeScript | d-klotz/google-dashboard | /src/app/dashboard/dados.service.ts | 2.703125 | 3 | import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { observable } from '../../../node_modules/rxjs';
@Injectable()
export class DadosService {
readonly dados = [
['Janeiro', 33],
['Fevereiro', 68],
['Março', 49],
['Abril', 15],
['Maio', 80],
['Ju... |
23219bb8be6b16beb7e6150fe223bf862616d3cb | TypeScript | cahilfoley/utils | /src/transforms/toProperList.ts | 4.09375 | 4 | /**
* @module transforms
*/
/**
*
* Joins together several strings or numbers in a properly formatted English list. The last two items are seperated by the word
* 'and' and the remaining items are seperated by a comma and space.
*
* @param items Array of strings
*
* @example
* ```typescript
*
* const items... |
fabdcb3d92319f086d29f758d7a9b166cb2a8df8 | TypeScript | michael8090/function-component | /src/functionComponent/functionComponent.ts | 2.75 | 3 | import { CrossList as CL, CrossListNode } from './CrossLinkedList';
import { MemoryPool } from './MemoryPool';
import { Queue } from './Queue';
// accessing a Module Symbol has overhead
const CrossList = CL;
const addCrossListNode = CrossList.add;
const walkCrossListNode = CrossList.walk;
const walkModifiedCrossListN... |
86b7f8f7e9cf411652337f9eb5f39092deda4d51 | TypeScript | Maks0123/factoryBusinessOptimisation | /pms-client/src/app/models/HR/employment-info.ts | 2.90625 | 3 | export class EmploymentInfo {
id: number;
employmentDate: Date;
dismissalDate: Date;
dismissReason: string;
constructor() {
this.id = -1;
}
clone(): EmploymentInfo {
const info = new EmploymentInfo();
info.id = this.id;
info.employmentDate = this.employmentD... |