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 |
|---|---|---|---|---|---|---|
f051415e87ab95c7d1693186e31b3548554f9387 | TypeScript | rnsell/ts-pattern-demo | /2-basic-pattern-examples/2-objects.ts | 3.5 | 4 | // Website
import { match, select } from "ts-pattern";
type Data = { type: "text"; content: string } | { type: "img"; src: string };
type Result = { type: "ok"; data: Data } | { type: "error"; error: Error };
const resultInput: Result = {
type: "ok",
data: {
type: "text",
content: "hello world",
},
};
... |
cbffcac01347811d97295f3d81da8ab2c38f8792 | TypeScript | huaweicloud/huaweicloud-sdk-nodejs-v3 | /services/sms/v3/model/UpdateTaskSpeedRequest.ts | 2.625 | 3 | import { UpdateTaskSpeedReq } from './UpdateTaskSpeedReq';
export class UpdateTaskSpeedRequest {
private 'task_id'?: string;
public body?: UpdateTaskSpeedReq;
public constructor(taskId?: string) {
this['task_id'] = taskId;
}
public withTaskId(taskId: string): UpdateTaskSpeedRequest {
... |
7307aba058e590ddda82f3561437421533d705d1 | TypeScript | Myns18/Ts_Bank | /app/index.ts | 2.734375 | 3 | import { Client } from "./Client";
import { Compte } from "./Comptes/Compte";
import { CompteASeuil } from "./Comptes/CompteASeuil";
import { CompteASeuilRemunere } from "./Comptes/CompteASeuilRemunere";
import { CompteRemunere } from "./Comptes/CompteRemunere";
const compte = new Compte();
compte.ajouter(5);
const c... |
f5bc7e869b6b37f08d0adc5383d1517d0a95c560 | TypeScript | GarboMuffin/garbomuffin.github.io | /nightlight/src/engine/vector.ts | 3.703125 | 4 | import { Vector2D } from "./vector2d";
/*
* A 3D Vector: (x, y, z)
*
* z is optional when creating Vectors
*/
// a simple position class that removes some verbosity from code
// can make for some nicer code sometimes
export class Vector extends Vector2D {
public z: number;
constructor(x: number | Vector = 0... |
d443233d2b1bb91ef455736de141d86bfbf04d8c | TypeScript | n-wach/protractr | /scripts/ui/history.ts | 3.78125 | 4 | /**
* @module ui/history
*/
/**
* Editing history manager. Consists of two stacks: undo and redo history.
* New states clear redo history, are added to undo history.
* It's possible for current state to be undefined, in which case the app should load some default state.
*/
export default class History<T = string... |
ccf8f2989203356a884d6500e0926d754585e4fd | TypeScript | horvay/simple-dux | /__tests__/store-test.ts | 3.34375 | 3 | import SimpleDux from "../src/index";
it("Successfully register a persistent store and retrieve it", () =>
{
let simple_dux = new SimpleDux();
let store = simple_dux.Store;
class Person
{
public name = "greg";
}
let greg: Person = { name: "greg" };
store.RegisterPersistentStore(gr... |
d422dd8deefe68f8f4be702099b6bb1119df97e5 | TypeScript | jmhalire/api-veterinaria | /src/models/usuario.ts | 2.8125 | 3 | import {Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, BeforeInsert, TableForeignKey, OneToMany} from "typeorm";
import bcrypt from "bcrypt";
import { Venta } from "./venta";
export enum UserRole {
ADMIN = "ADMIN",
GENERAL = "GENERAL"
}
@Entity()
export class User {
... |
edb15b31e2198976eb56b2627f77ab16e160e9f5 | TypeScript | jacoor/complete-typescript-course | /shared/model/course-detail.ts | 3.03125 | 3 | import { Lesson } from "./lesson";
import { CourseSummary } from "./course-summary";
// type could be used here, however since this is object type
// interface is recommended.
export interface CourseDetail extends CourseSummary {
longDescription: string;
comingSoon?: boolean;
isNew?: boolean; //optional
isOng... |
26b0133309ae6335f8d89bdbacffbeeb7a195d6e | TypeScript | faruzzy/snake | /src/Shape/Matrix.test.ts | 2.765625 | 3 | import { fromJS } from 'immutable'
import { Matrix } from './Matrix'
describe('Matrix', () => {
const matrix = Matrix.fill([3, 2], 0)
test('generated matrix', () => {
expect(matrix.rows.toJS()).toEqual([
[0, 0, 0],
[0, 0, 0],
])
})
it('is a functor', () => {
expect(matrix.map((cell, [... |
e680056b40648987631e0b1071b57f94a269214a | TypeScript | angus-c/just | /packages/string-replace-all/index.d.ts | 2.703125 | 3 | type ReplaceAll<
Str extends string,
SubStr extends string,
NewSubStr extends string
> = Str extends `${infer Before}${SubStr}${infer After}`
? `${Before}${NewSubStr}${ReplaceAll<After, SubStr, NewSubStr>}`
: Str;
declare function replaceAll<
Str extends string,
SubStr extends string,
NewSubStr extends... |
6c1036a8692bbeff54885c815d2572bbd1da18b5 | TypeScript | huddle-brasil/slush-ts-functions-firestore | /templates/functions/src/utils/crossDomain.ts | 2.578125 | 3 | import { Request, NextFunction, Response } from "express";
export const crossDomain = (req: Request, res: Response, next: NextFunction) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS,PATCH');
res.header('Access-Control-Allow-Head... |
ba2fe1f19d3df934f1c124c91970ef3a10eb939c | TypeScript | mudachyo/pixelplanet-bot | /src/userInput.ts | 2.8125 | 3 | import * as readline from 'readline';
import logger from './logger';
export interface IProgramParameters {
xLeftMost: number;
yTopMost: number;
imgPath: string;
ditherTheImage: boolean;
constantWatch: boolean;
doNotOverrideColors: number[];
customEdgesMapImagePath: string;
}
class UserInpu... |
5b85dc5e9ced041e9e8495583757f0d7f340826d | TypeScript | smkamble/protractor-jasmine-typescript-framework | /Library/PropertyFileReader.ts | 2.578125 | 3 | /**
* Created by Deepak on 07/02/18.
*/
import {isNullOrUndefined} from "util";
import {Constants} from "./Constants";
const propertiesReader: any = require("properties-reader");
let propFile: any = "";
export class PropertyFileReader {
private static pfReader: PropertyFileReader;
// private logger: any = Const... |
ef9b989bdb4a2e4b50b58c7935b8db917e0ff329 | TypeScript | pcsteppan/ghost-bot | /src/Test.ts | 3.390625 | 3 | import TrieNode from "./Trie";
import { StateMachine, State } from "./StateMachine";
import { StateEvent } from "./Types";
import { shuffleArray } from "./Utils";
const dict = require('../resources/dict.json');
const assert = require('assert');
const {performance} = require('perf_hooks');
describe('Trie', () => {
... |
52911da7a988b6f0b1dc5d06ae05d88fa44d502c | TypeScript | leo2707/learningEglish_APP | /learning-english/src/app/util/util.ts | 2.890625 | 3 | export class Util {
static getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
static generateRequestId(){
return new Date().getTime() + this.getRandomInt(1,100);
}
} |
aae0c3a929faa0a17af7afcc58a3ca8c56e6dd5f | TypeScript | 1ziton/pixelmon | /packages/theme/src/services/i18n/i18n.ts | 2.546875 | 3 | import { Injectable, InjectionToken } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { filter } from 'rxjs/operators';
export interface PixelmonI18NService {
[key: string]: any;
/**
* 调用 `use` 触发变更通知
*/
readonly change: Observable<string>;
/**
* 变更语言
* @param lan... |
6171c548c1b01b54fc22d5034ce339de12ec1b7d | TypeScript | ofirgeller/cache-ms | /src/cache.controller.ts | 2.609375 | 3 | import { ForbiddenException, HttpCode, Query, Req } from '@nestjs/common';
import { Controller, Delete, Get, NotFoundException, Post } from '@nestjs/common';
import { FastifyRequest } from 'fastify'
import { LRU } from './LRU';
const isLoopbackAddr = require('is-loopback-addr');
@Controller()
export class CacheControl... |
17dcc992d0ee01eb6e4a86266cfaacdf4d0237d6 | TypeScript | RetroAstro/data-structures-and-algorithms | /src/data-structures/binary-tree/node.ts | 2.75 | 3 | export class Node<T> {
left: Node<T> = null
right: Node<T> = null
parent?: Parent<T>
constructor(public data: T) {}
}
export class Parent<T> {
constructor(public node: Node<T>, public path: string) {}
}
|
3e854a3c035121b44217985be58be22f4decb03d | TypeScript | dqube/simple-ui | /tools/release/version-name/publish-branches.ts | 3.25 | 3 | import { Version } from './parse-version';
export type VersionType = 'major' | 'minor' | 'patch';
/** 确定用于发布指定版本的允许分支名称 */
export function getAllowedPublishBranches(version: Version): string[] {
const versionType = getSemverVersionType(version);
if (versionType === 'major') {
return ['master'];
} else if (... |
870a659e3e442195aa25c744a5070bbe356b3763 | TypeScript | jinderSingh/decorators | /src/decorators/excel-column.decorator.ts | 2.84375 | 3 | import { CELL_VALUE_TRANSFORMER, COLUMN_NAMES, COLUMN_NUMBERS, EXCEL_METADATA, PROP } from '../constants/constants';
import { hasValue, isFunction } from '../util-methods';
import { ExcelColumnType } from './../models/excel-column.type';
/**
* Sets metadata to class type
* @param param0
* @param transformer
*/
e... |
740d38f5246fb0b2f7f9ecf5480f584508ec8a12 | TypeScript | Spark-NF/novel-updates-notifier | /src/common/time.spec.ts | 2.75 | 3 | import { secondsToString } from "./time";
describe("secondsToString", () => {
it("Works with hours", () => {
expect(secondsToString(7 * 60 * 60 + 27 * 60 + 17, true)).toBe("7:27:17");
expect(secondsToString(27 * 60 + 17, true)).toBe("0:27:17");
expect(secondsToString(17, true)).toBe("0:00:1... |
071498f59f987d36657cd0249d7335bd537d8b20 | TypeScript | Davitron/ays-server | /src/shared/interceptors/error.filter.ts | 2.546875 | 3 |
import { Injectable, ExceptionFilter, Catch, ArgumentsHost, HttpException, HttpStatus } from '@nestjs/common';
import { Response } from './response.interceptor';
const handleValidationError = (error: any) => {
const response = error.map(err => {
const { property, constraints } = err;
return { property, cons... |
27f365a802afe29532e318af59341eccc3c26c1e | TypeScript | pjayneet97/1st-year-angular-project1 | /src/app/testcomp/testcomp.component.ts | 2.734375 | 3 | import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-testcomp',
templateUrl: './testcomp.component.html',
styleUrls: ['./testcomp.component.css']
})
export class TestcompComponent implements OnInit {
number1:number;
number2:number;
resultAvailable:boolean=false;
resultColor='red... |
96a35b09edb7d3a655f67b3f1a8bba97e7fe2bdb | TypeScript | s-skubedin/react-picture-annotation | /src/annotation/CreatingAnnotationState.ts | 2.53125 | 3 | import { ReactPictureAnnotation } from "../index";
import { IAnnotationState } from "./AnnotationState";
import { DefaultAnnotationState } from "./DefaultAnnotationState";
import Transformer from "../Transformer";
export default class CreatingAnnotationState implements IAnnotationState {
private readonly context: Re... |
c373f5995ba46cb06bf98578a5f790314d7f10bc | TypeScript | blsnwbrdr/traveltracker-ng-app | /src/app/list/list.component.ts | 2.734375 | 3 | import { Component, OnInit } from '@angular/core';
// INTERFACES
import { ICountry } from '../interfaces/country.model';
// SERVICES
import { CountriesService } from '../services/countries.service';
import { LocalStorageService } from '../services/local-storage.service';
@Component({
selector: 'app-list',
templa... |
54d0b3154add0530b2dd1c164dd08068f1d9172a | TypeScript | G3F4/moxy-proxy | /src/common/hooks/useLocalstorage.ts | 3 | 3 | import { useCallback, useState } from 'react';
export default function useLocalstorage<T>(key: string, initialValue: T) {
const [storedValue, setLocalValue] = useState(() => {
try {
const item = window.localStorage.getItem(key);
return item ? JSON.parse(item) : initialValue;
} catch (error) {
... |
c59eff5e0bb07f4049d3434fb4b1672d11eae856 | TypeScript | vigneshpa/ffmpeg-wasm | /package/src/index.worker.ts | 2.78125 | 3 | //interfaces
interface Options {
distFolder: string;
tool: ("ffmpeg" | "ffprobe");
args: string[];
bufferSize: number;
getStdErrFile: boolean;
getStdOutFile: boolean;
}
interface EmscriptenModule {
FS: typeof FS;
IDBFS: Emscripten.FileSystemType;
WORKERFS: Emscripten.FileSystemType;
... |
35afa9332bd06f846617f883ec5a0f4b6793bc8b | TypeScript | teyrana/annum | /src/storage_type.ts | 3.25 | 3 | export class StorageType {
readonly name: string;
private readonly _code: number;
private static lookup = new Map<number,StorageType>();
constructor(n:string, id:string){
this.name = n;
this._code = id.charCodeAt(0);
StorageType.lookup.set( this._code, this);
}
static readonly ABSTRACT = ... |
6fd1de43a07dcda0ff44fab829d2d67b34b110af | TypeScript | SOUNDBOKS/react-native-interactable | /lib/src/PhysicsAnchorBehavior.ts | 2.78125 | 3 | import { PhysicsBehavior } from "./PhysicsBehavior";
import { IPoint, ITarget } from "./types";
import { PhysicsObject } from "./PhysicsObject";
export class PhysicsAnchorBehavior extends PhysicsBehavior {
initWithTarget(target: ITarget, anchorPoint: IPoint) {
super.initWithTarget(target, anchorPoint);
... |
59831f3add968989075928ce5a8ee9057d99d883 | TypeScript | SergeyKirintsev/JavaScript-Total | /assets/patterns/typescript/creational/prototype.ts | 3.8125 | 4 | /**
* Пример класса, имеющего возможность клонирования. Мы посмотрим как происходит
* клонирование значений полей разных типов.
*/
class Prototype {
public primitive: any
public component: object
public circularReference: ComponentWithBackReference
public clone(): this {
const clone = Object.create(this... |
6a05b248fce1856c5543a5a8e512166f2ec9a409 | TypeScript | buurperezoso/bingo | /src/utils/index.ts | 2.875 | 3 | import { CardElement } from "../interfaces/Cards";
export const removeItemFromArray = (cardsArray: CardElement[], index: number) => {
if (index > -1) {
cardsArray.splice(index, 1);
}
return cardsArray;
};
export const findElementInArray = (indexValue: number, array: number[]) => {
return array... |
da3b33017017f06d51b12410b208c13cdc66620c | TypeScript | LukasMirbt/learning-system | /src/Media/getSearchableSections.ts | 2.65625 | 3 | import { SearchableSection, Section } from "./Media";
const getSearchableSections = (sections: Section[], title: string) => {
const searchableSections: SearchableSection[] = [];
sections.forEach(({ sectionName, startTime, endTime, chapters }) => {
searchableSections.push({
text: sectionName,
start... |
1729115dcda5117d56ef965e7509a9c6479847c8 | TypeScript | SiddAjmera/Instagram | /src/app/models/gender.enum.ts | 2.578125 | 3 | export enum Gender {
Male = 'Male',
Female = 'Female',
NotSpecified = 'Not Specified'
} |
5e5bbf51ba314706f749c6314b6c75f421748d38 | TypeScript | nghiepdev/prevent-orientation | /index.ts | 2.6875 | 3 | export class PreventOrientation {
private text: string;
private color: string;
private background: string;
private fontSize: string;
private angle: string | number = 0;
private readonly className: string = 'wrapper-prevent-orientation';
constructor({
text = 'Sorry, this device orientation is not supp... |
8fd179c3fd503d54059966c35f9b7ccb8597efde | TypeScript | jamilur-r/skill-mask | /apps/api/src/controller/Category.ts | 2.59375 | 3 | import { Request, RequestHandler, Response } from 'express';
import Category from '../model/Category';
import * as fs from 'fs';
import * as path from 'path';
export const getAllCategories: RequestHandler = async (_, res: Response) => {
try {
const data = await Category.find();
return res.status(200).json(da... |
1e4d8d959ad40145ecb7de6ad463fe0a64c45f72 | TypeScript | mariatrojo/MEAN-TypeScript-Bikes-OOP | /tsBikesOOP.ts | 3.765625 | 4 | class Bike {
miles: number = 0;
allInfo: string;
constructor(
public price: number,
public max_speed: string) { }
//ISSUE: arrow is needed since this function is called by another function.
ride = () => {
for (var i = 0; i < 10; i++) {
this.miles++;
}
... |
6839dabd7a7e7b0135870a1bff600dbef40c8ab5 | TypeScript | ziponia/oauth2orize-examples | /src/routes/oauth2.ts | 2.609375 | 3 | "use strict";
import oauth2orize from "@poziworld/oauth2orize";
import passport from "passport";
import login from "connect-ensure-login";
import db from "../db";
import * as utils from "../utils";
// Create OAuth 2.0 server
const server = oauth2orize.createServer();
// Register serialization and deserialization fun... |
aff5292129b74e7cdb6436ff8e9ced79b3f67996 | TypeScript | suraj-dev/PayrollManager- | /SB-Admin-BS4-Angular-5-master/src/app/layout/list-of-employees/list-of-employees.component.ts | 2.515625 | 3 | import { Component, OnInit } from '@angular/core';
import {NgbModal, NgbModalRef} from '@ng-bootstrap/ng-bootstrap';
import {EmployeeService} from "../../services/employee.service";
import {IEmployee} from "../../interfaces/IEmployee";
/**
* This component serves data to the list of employees view and interacts with ... |
5c70ccd2859ec5e05c3bf3a0064ab3bb76970d21 | TypeScript | future4code/Noh-Ah-Jeong | /semana19/labook/src/data/userDatabase.ts | 2.515625 | 3 | import { User } from "../business/entities/user"
import { connection } from "./connection"
const usersTableName = "labook_users"
export const insertUser = async (user: User) => {
await connection.raw(`
INSERT INTO ${usersTableName} (id, name, email, password)
VALUES ("${user.id}", "${user.name}", ... |
10a2d51019b50261490c5e64536857c9410fc301 | TypeScript | Hendrik6/Nasa-Deno | /models/planets.test.ts | 2.609375 | 3 | //Deno Includes
import {
assertEquals,
assertNotEquals,
} from "../test_deps.ts";
import * as log from "https://deno.land/std/log/mod.ts";
import { filtersHabitablePlanets } from "./planets.ts";
//Test runner in the CLI
//Built in text fixtures with Deno.test().
//Assertion statements
const HABITABLE_PLANET = {... |
c62fafc1fddc1f31a866f7e2f437e8c344d85c80 | TypeScript | brady-miller/todo-api | /src/middlewares/auth.ts | 2.609375 | 3 | import { Response, NextFunction } from "express";
import { IUserRequest } from "../interfaces/IUserRequest";
import jwt from "jsonwebtoken";
import dotenv from "dotenv";
import { User } from "../models/user";
dotenv.config()
let {
JWT_SECRET
}: NodeJS.ProcessEnv = process.env;
if (!JWT_SECRET) throw new Error('En... |
310724c7096bec6efc253f3c76f7cdbd5d2a2977 | TypeScript | SuperVK/RLBotVK | /src/states/Orient.ts | 2.65625 | 3 | import BaseState from "./BaseState";
import Agent from '../Agent'
import { Vector3 } from "../utils/misc";
export default class Orient extends BaseState {
localTarget: Vector3;
target: Vector3;
hasJumped: Boolean;
constructor(agent: Agent, target: Vector3) {
super(agent, 'ORIENT')
this.... |
34622804a9dea27dde6a997be5d4b2fd6e46df34 | TypeScript | serhat2806/hrms-etiya | /src/app/features/candidate/candidate-sign/candidate-sign.component.ts | 2.609375 | 3 | import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ToastrService } from 'ngx-toastr';
import { CandidateService } from 'src/app/services/candidate.service';
import { UserService } from 'src/app/services/user.service';
@Component({
selector... |
bfab8264307661f6e9fc6e3e386f8ff7697edb01 | TypeScript | Bash360/premier-league-api | /src/models/user.ts | 2.609375 | 3 | import { Schema, model } from 'mongoose';
import Iuser from '../typings/user';
import uuid from 'uuid/v4';
import jwt from 'jsonwebtoken';
import bcrypt from 'bcrypt';
require('dotenv/config');
import uniqueValidate from 'mongoose-unique-validator';
let secret: string = `${process.env.SECRET}`;
import toLower from './t... |
99fcdfcb2dc8ee495bb4239fb4e03b98924b4540 | TypeScript | frosit/odata-edm-generator | /tests/templates.spec.ts | 2.5625 | 3 | import { assert } from 'chai';
import mockFs from 'mock-fs';
import { join } from 'path';
import { v4 as uuid } from 'uuid';
import { Configuration } from '../src/cli/configuration';
import { ClassInfo, EdmInfo, EnumInfo, ComplexTypeInfo, PropertyInfo, ComplexTypeInfoSet } from '../src/cli/shared';
import { EdmTemplate... |
921a59919a35732a3315d552eb71d1eeba4c8cc6 | TypeScript | g-plane/TypeCake | /tests/compiler/snapshots/if-expression/else-if/output.ts | 2.765625 | 3 | type Check<T> = T extends string ? 'a string' : T extends number ? 'a number' : 'something else';
|
b950427700e254ec87b7f91ff001dc9512377c25 | TypeScript | maertz/ngx-uploadx | /src/uploadx/lib/uploader.spec.ts | 2.625 | 3 | // noinspection ES6PreferShortImport
import { ErrorHandler } from './error-handler';
import { Uploader } from './uploader';
// tslint:disable: no-any
function getFile(): File {
return new File(['-'], 'filename.mp4', { type: 'video/mp4', lastModified: Date.now() });
}
const file = getFile();
const snip = { file, si... |
06c952effdbb953eff76922641754cf603954f48 | TypeScript | gecosys/cso-client-typescript | /src/messages/ticket/ticket.ts | 3.515625 | 4 | export class Ticket {
ID: number;
Token: Uint8Array;
// ParseBytes converts bytes to Ticket
// ID: 2 bytes
// Token: next 32 bytes
public ParseBytes(buffer: Uint8Array) {
if (buffer.byteLength != 34) {
return null;
}
let temp = new Uint16Array(1);
temp[0] = (buffer[1] << 8) | buffer[0... |
e053ecdf4d67ba1a44476a367f36d6414d8156b4 | TypeScript | brendy/Incredibots-2-HTML5-Open-Source | /src/Actions/MultiOutlineAction.ts | 2.59375 | 3 | import { Action } from "../imports";
export class MultiOutlineAction extends Action
{
private outline:boolean;
private partsAffected:Array<any>;
constructor(parts:Array<any>, outlineVal:boolean)
{
super(parts[0]);
this.partsAffected = parts;
this.outline = outlineVal;
}
public UndoAction():void {
for (... |
1a8af2895ce6349d0923e1784df2b26da597e232 | TypeScript | MtyldZ/node-app | /src/errors/forbidden.error.ts | 2.640625 | 3 | import {HttpError} from './http-error';
export class ForbiddenError<T> extends HttpError<{ error_body_message: string, details: T }> {
constructor(message: string, details?: T) {
super(403, {error_body_message: message, details});
}
}
|
ac07a3a5cb6d5874363cab94e744a88fe1fdc0fa | TypeScript | munxar/quarto | /frontend/src/app/toast/toast.ts | 2.578125 | 3 | ///<reference path="../../../../mithril.d.ts"/>
import * as m from "mithril";
import {LoggerService, LogLevel} from "../service/LoggerService";
import "./toast.css!css";
class Toast {
constructor(public message: string, public level: LogLevel) {
}
}
class ToastController {
toasts: Toast[] = [];
con... |
c0a834daa3affb5e14418b5603566f2c42377679 | TypeScript | zhf/typescript-rest-starter | /src/App.ts | 2.515625 | 3 | import * as express from 'express'
import * as bodyParser from 'body-parser'
import { test } from './test'
class App {
public express
constructor () {
this.express = express()
this.mountRoutes()
}
private mountRoutes (): void {
const router = express.Router()
router.get('/', (req, res) => {
... |
6e086e914df84eb4fce3f781a5ff8d6c2b35e4c8 | TypeScript | kml1990/products-listing | /src/provider/mocky/MockyProductParser.ts | 2.71875 | 3 | import Product from '../../product/Product';
import ProductPrice from '../../product/ProductPrice';
import { ProductsParser } from '../ProductParser';
import { MockyProduct } from './MockyTypes';
export default class MockyProductParser implements ProductsParser<MockyProduct> {
parse(products: MockyProduct[]): Prod... |
9243be216d0acf3cff8eecc8b7cce9aacfc748cd | TypeScript | minhtrung2606-work/my-first-ng4-app | /Inventory/src/app/components/product-list/product-list.component.ts | 2.796875 | 3 | import { Component, OnInit, Input, Output, EventEmitter, HostBinding } from '@angular/core';
import { Product } from './../../product';
@Component({
selector: 'product-list',
templateUrl: './product-list.component.html',
styleUrls: ['./product-list.component.css']
})
export class ProductListComponent implements ... |
4321726efffa653212a00a3dfb3ba123712dc5e7 | TypeScript | fun4wut/mltd-zh-functions | /lib/capture/magic.ts | 2.609375 | 3 | import CryptoJS from 'crypto-js'
import tmpUtil from 'tmp'
import { gzip } from 'compressing'
import { promises as fs } from 'fs'
const secretKey = process.env.MLTD_KEY!
const secretKeyHash = CryptoJS.enc.Utf8.parse(secretKey)
const decBase = (str: string) => {
const s = str.replace(/-/g, '+').replace(/_/g, '/')
... |
dafbde288027b35ec780a913d7e5124b32f495ce | TypeScript | kavusiks/SellPoint | /sellpoint_frontend/src/models/ad.ts | 3.046875 | 3 | import User from "./user";
/**
* An image belonging to a specific Ad
*/
export interface AdImage {
/**
* The unique ID of this image
*/
id: number;
/**
* URL pointing to the image file
*/
url: string;
/**
* Textual description of this image
*/
description: string;
}
/**
* A posted ad
... |
c4736fc7542d6bae5bdb63af32385c74ed967ddc | TypeScript | caioguilherme10/projectthree-server | /src/resolvers/pasciente.ts | 2.71875 | 3 | import { Query, Resolver, Arg, Int, Mutation } from "type-graphql";
import { getConnection } from "typeorm";
import { Pasciente } from "../entities/Pasciente";
import { PascienteInput } from "./types/pasciente-input";
@Resolver(Pasciente)
export class PascienteResolver {
//ADMINISTRADOR
@Query(() => [Pascient... |
4a119bc7ec86dc8f7f78c490eb2613ff4196f628 | TypeScript | heatherwenzel/angular-recipe-api | /src/app/search-criteria/search-criteria.component.ts | 2.65625 | 3 | import { Component, OnInit } from '@angular/core';
import { RecipeService } from '../recipe.service'; //added
@Component({
selector: 'search-criteria', //deleted app
templateUrl: './search-criteria.component.html',
styleUrls: ['./search-criteria.component.css']
})
export class SearchCriteriaComponent implements ... |
a790613a88a61b1f54f7d5bb6d750dad57d3b290 | TypeScript | glazar/ts-jest-enum-issue | /src/files/file1.ts | 2.765625 | 3 | import { ColorEnum, consoleLog } from "./file4";
export const square = (x: number) => x * x;
export const cube = (x: number) => x * x * x;
export const consoleLogSquare = (x: number) => consoleLog(square(x));
export const consoleLogCube = (x: number) => consoleLog(cube(x));
export enum NumberEnum {
Zero = 0,
One... |
99b0bfac257bcde595055e7a0b71532dfecf117c | TypeScript | fyfey/tic-tac-toe | /lib/dist/logger.d.ts | 2.578125 | 3 | export interface Logger {
info(...messages: string[]): void;
error(...messages: string[]): void;
}
export declare class NullLogger implements Logger {
info(...messages: string[]): void;
error(...messages: string[]): void;
}
export declare class ConsoleLogger implements Logger {
info(...mess... |
a709bea4769e277160f2ca1b99d418da0f317d99 | TypeScript | titiksha07/Assignment12.3 | /src/app/capital.pipe.ts | 2.71875 | 3 | import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'capital',
pure: false
})
export class CapitalPipe implements PipeTransform {
transform(value: string): string {
let fStr:string='';
let restStr:string='';
let newStr:string='';
if (value.length !== 0) {
fStr= value.charAt... |
aa5e651d3dd02aac235586b1cecd6647017367df | TypeScript | mvfsillva/find-quebec-montreal-bus | /src/hooks/use-click-away.ts | 2.53125 | 3 | // Packages
import { useRef, useEffect } from 'react'
const useClickAway = (effect: () => void) => {
const node = useRef<HTMLInputElement>(null)
const handler = (event: Event) => {
const { target } = event
if (node && node.current) {
if (node.current.contains(target as Node)) return
effect()... |
d9bbc485936a8ef6ace5ae1e2b6c4839346ad0b0 | TypeScript | uparlange/msdb-ts | /src/app/common/managers/favorites-manager.ts | 2.640625 | 3 | import { AbstractManager } from '../../fwk/abstract-manager';
import { CacheManager } from '../../fwk/managers/cache-manager';
import { EventEmitter, Injectable } from '@angular/core';
@Injectable({ providedIn: "root" })
export class FavoritesManager extends AbstractManager {
private _favorites: Array<string> = new... |
2e40d04cfb2653b533ad51383beb738c7678fae7 | TypeScript | flyrootmedia/udemy-typescript | /01-features/classes.ts | 4.28125 | 4 | class Vehicle {
// properties CAN be initialized when declared here
// public color: string;
// public weight: number;
// to set properties as args when creating an instance, they must be set in
// the constructor method. Note now all args will be required by instances
// constructor(color: string, weight:... |
d35dd8529037873b20351bf1e3bbec26db5c89ed | TypeScript | johniyere/offroads-web-v1 | /src/app/account/shared/time-view.pipe.ts | 2.640625 | 3 | import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'timeView'
})
export class TimeViewPipe implements PipeTransform {
transform(value: number, args?: any): any {
const hours = Math.round(value / 3600);
const hoursRem = Math.round(value % 3600);
const min = Math.round(hoursRem / 60);
... |
d8cd63ed26b1abfcdb8ec26aa1f43c18c8ed332e | TypeScript | Renddslow/y | /src/types.ts | 2.515625 | 3 | export type Character = {
age: number;
birthday: number;
tribe: string;
name: string;
};
export type State = {
day: number;
playRate: 1 | 2 | 3;
paused: boolean;
character: Character;
};
export type Game = {
stop: number;
lastTick: number;
tickLength: number;
lastRender: number;
gameStart: n... |
1ded8567fe53e911c79b5f7a63c1f1482a9992ce | TypeScript | wasabi-io/tdd-suite | /src/renderer/electron/Browser.ts | 2.53125 | 3 | import BrowserWindowOptions = Electron.BrowserWindowOptions;
import Window, {WindowProps} from "./Window";
export interface BrowserProps extends WindowProps {
onDestroy();
}
export default class Browser extends Window {
public constructor(props: BrowserProps) {
super(props);
}
public destroy... |
a7701336352e00985d09bd2b30104fc1cdf991f7 | TypeScript | nodegui/nodegui | /src/examples/modelview_3_changingmodel.ts | 2.546875 | 3 | import { ItemDataRole, QAbstractTableModel, QModelIndex, QTableView, QVariant } from '..';
function main(): void {
const tableView = new QTableView();
const model = new MyModel();
tableView.setModel(model);
tableView.show();
setInterval(() => {
model.timerHit();
}, 1000);
(global... |
72070778b698dddac84a444fe2ad29c5f41de30a | TypeScript | m8r1x/sakilagql | /src/schema/__tests__/customer.test.ts | 2.921875 | 3 | import test from 'ava';
import { api } from './api';
function getDocument(query: string) {
return `${query}
fragment AllCustomerProperties on Customer {
firstName
lastName
email
active
createdDate
lastUpdate
address { addressName }
}... |
3ef9ef5b0b282e51739f1c04e973ef1f0efbca8c | TypeScript | rheehot/metaflow-ui | /src/components/Timeline/taskdataUtils.ts | 2.921875 | 3 | import { Step, Task, TaskStatus } from '../../types';
import { RowDataModel } from './useTaskData';
//
// Counts rows
//
export type RowCounts = {
all: number;
completed: number;
running: number;
pending: number;
failed: number;
unknown: number;
};
export function countTaskRowsByStatus(rows: RowDataModel... |
54fd9855e43f5944ff33605cd7e3841ada8f25cf | TypeScript | mweels/aphajs | /src/test/Exception.spec.ts | 2.953125 | 3 |
import {expect} from "chai";
import {Exception} from "../main/Exception";
describe("Exception", () => {
it("should be filled with sense-making values", () => {
const e = new SomeDerivedException("my message");
expect(e).to.be.an.instanceOf(SomeDerivedException);
expect(e).to.be.an.instanc... |
439c17fa52d01c1d72f9997d6e1862f8a272d94d | TypeScript | NicolasFkm/BankApp | /src/controllers/AccountController.ts | 2.515625 | 3 | import { HttpStatus } from '@enumerators/HttpStatus';
import { DataNotFoundException } from '@helpers/errors/DataNotFoundException';
import { InvalidArgumentException } from '@helpers/errors/InvalidArgumentException';
import { IAccount } from '@models/Account';
import EntityCollectionResponse from '@models/responses/En... |
c98f863c055d0b2381772760ff61fdfb627f743a | TypeScript | Badaboom1995/mining | /server/src/app/workers/miner-stats/currency-api/currency-transaction.ts | 2.65625 | 3 |
export interface ICurrencyTransaction {
/**
* Transaction type
* @type {string}
* @memberof ICurrencyTransaction
*/
type? : string;
/**
* Transaction value
*/
value : number;
/**
* Transaction time
* @type {number}
* @memberof ICurrencyTransaction
*/
timestamp : number;
/**
* Transacti... |
5699240b314f8d29131516d44a393432aaf5c466 | TypeScript | JingYang0521/permission-management-system | /src/utils/storage.ts | 2.765625 | 3 | export const rmLocalStorageItem = (key: string) => {
localStorage.removeItem(key);
};
export const getLocalStorageItem = (key: string): string | null => {
return localStorage.getItem(key);
};
export const setLocalStorageItem = (key: string, value: string) => {
return localStorage.setItem(key, value);
};
export... |
e9b0fc1e1bb6374442aaa48cd8f089cd133cf6bc | TypeScript | ZanovelloAlberto/PixiRPG | /src/game/map/Player.ts | 2.796875 | 3 | /*
*/
import { BaseTexture, Rectangle, Sprite, Texture } from 'pixi.js';
import { textSpanIntersectsWithPosition } from 'typescript';
import { Res } from '../../Res';
import { Map } from '../map/Map'
export class Player extends Sprite {
textures: Array<Texture>;
running: boolean = false;
direction: nu... |
64ff033918a3d364aaeb61c3ce31cef5f1f44829 | TypeScript | Ericki/chronicler | /src/app/shared/services/crud-data.service.ts | 2.625 | 3 | import { Injectable } from '@angular/core';
import { AngularFireDatabase, AngularFireList } from '@angular/fire/database';
import * as firebase from 'firebase/app';
import 'firebase/storage';
import { FileUpload } from '../models/image';
@Injectable({
providedIn: 'root'
})
export class CrudDataService {
private ... |
6f1a216a76e697cc40a7fdb2e49f986fda0e04e9 | TypeScript | sutherlanda/hire-or-fire | /src/app/components/employee-list/employee-list.component.ts | 2.765625 | 3 | import { Component, OnInit, Input } from '@angular/core';
import { Employee } from 'src/app/models/employee.model';
import { Category } from 'src/app/models/category.model';
@Component({
selector: 'app-employee-list',
templateUrl: './employee-list.component.html',
styleUrls: ['./employee-list.component.scss']
})
ex... |
875992af6e71cba42bf4c8b9c7df64c7bddc8ab0 | TypeScript | RickvanB/Avans-Projects | /mobile-dev-hybrid/src/app/services/pokemon.service.ts | 2.515625 | 3 | import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { environment } from '../../environments/environment';
import { Observable } from 'rxjs';
import { Pokemon, PokemonWrapper } from '../models/API_model';
@Injectable({
providedIn: 'root'
})
export class PokemonServic... |
5d734d86f1a6fc6de45de9227f3bd6876e83e7b7 | TypeScript | bowen-wu/ts | /ts-demo/min.ts | 4.46875 | 4 | // 重载
function add (a: string, b: string): string;
function add (a: number, b: number): number;
function add (a: any, b: any): any{
return a + b;
}
// 返回值 类型
function min(a: number, b: number): number {
if(a > b) {
return b;
} else {
return a;
}
}
// 枚举
enum Gender {
Male,
Fema... |
0bb77ba1bb00b18a348d78f69b58da9c7c4543a1 | TypeScript | lorefnon/vulcyn | /src/expr/Update.ts | 3.296875 | 3 | import { Expr, PickExpr } from "./Expr";
import { Infix } from "./Infix";
import { ReductionContext } from "./ReductionContext";
import { SQLFragment } from "./SQLFragment";
import { Where } from "./Where";
/**
* An array of updates.
*
* This type requires that at least one update be defined (since
* `UPDATE ... S... |
6c4e17742cabc7964662001a8cfe87a0d334504d | TypeScript | piotrszyma/studies-system-security-2 | /server/crypto/hash.ts | 3.03125 | 3 | import * as crypto from 'crypto';
const R = '0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001';
/**
* Creates a string of int modulo R of BigInt from sha3-512 hash.
*/
export function stringifiedIntHashOf(value: string): string {
const hasher = crypto.createHash('sha3-512');
hasher.update(valu... |
af4c1fd46d1cca190dc22804f18d8fc39c0775a9 | TypeScript | zsiegel92/mitzvah_scheduler | /mitzvah/src/app/DoubleDate.ts | 2.96875 | 3 | import * as Hebcal from 'hebcal';
import {NgbDateStruct} from '@ng-bootstrap/ng-bootstrap';
const now = new Date();
export class DoubleDate {
greg: NgbDateStruct;
hyear: number;
hmonth: number;
hdate: number;
hday: number;
hdays_in_month: number;
hgregorian: Date;
hgregorian_eve: Date;... |
98f4d1b3b55d67f1f5b77adea74fbdf7fb431187 | TypeScript | AkramiPro/persian-tools | /src/helpers/index.ts | 2.90625 | 3 | export const trim = (str: string): string => str.replace(/^\s+|\s+$/g, "");
interface ReplaceArrayDictionary {
[key: string]: string;
}
export const replaceArray = (string: string, find: ReplaceArrayDictionary): string => {
const pattern = new RegExp(Object.keys(find).join("|"), "gi");
return string.replace(patter... |
6ccef4f0e559016b22bc76f6f295c4ea7db3b678 | TypeScript | jsalazar7/react-class-project | /vote-app/src/models/elections/Election.ts | 2.6875 | 3 | export type Election = {
id: number,
title: string,
questions: QuestionEntry[],
voters: number[],
}
export type QuestionEntry = {
id: number,
question: string,
yes: number, // Total number of 'yes' responses
}
export type ElectionKeys = 'id' | 'title' | 'questions';
export type NewElection... |
e09289df48b763f34ada678f8b2babb82d195bc3 | TypeScript | ceefour/webiny-js | /packages/api-security-tenancy/src/crud/paginateBatch.ts | 2.859375 | 3 | type TItem = Record<string, any>;
export const paginateBatch = async <T = TItem>(
items: T[],
perPage: number,
execute: (items: T[]) => Promise<any>
) => {
const pages = Math.ceil(items.length / perPage);
for (let i = 0; i < pages; i++) {
await execute(items.slice(i * perPage, i * perPage +... |
9715d405bafdfed76ea56a67194cb877c5f54f44 | TypeScript | fc7/astronomia | /src/node.d.ts | 2.6875 | 3 | /**
* @copyright 2013 Sonia Keys
* @copyright 2016 commenthol
* @license MIT
* @module node
*/
export = node;
export as namespace node;
declare module node {
/**
* EllipticAscending computes time and distance of passage through the ascending node of a body in an elliptical orbit.
* Argument axis is s... |
808bda891a58ade508b9bdffd56caa32a4965dc6 | TypeScript | ILovePug/udemy-express-ts | /src/controllers/decorators/controller.ts | 2.828125 | 3 | import 'reflect-metadata'
import { AppRouter } from '../../utili/AppRouter'
import { Methods } from './Methods'
import { MetadataKeys } from './MetadataKeys'
import {Request, Response, RequestHandler, NextFunction } from 'express';
function bodyValidators(keys: string):RequestHandler{
return function(req: Request,... |
7a90767729cc7dee364980419cf6ab12dc48afe6 | TypeScript | theLAZYmd/election | /src/Voter.ts | 3.015625 | 3 | import { Vote } from "./VoteInterfaces";
import Race from './Race';
import { Threshold } from "./ElectionInterfaces";
export default class Voter {
static properties: string[] = [];
static thresholds: Threshold<Voter>[] = []
public id: string = '';
public name: string = '';
public votes: {
[key: string]: Vote
... |
a0cb502e176c05d69af1be0ecd5d6e8d366a3d6f | TypeScript | jamalashraf0406/Angular | /my-account/src/app/logging.service.ts | 2.734375 | 3 | /**
* Here we didn't use @Injectable() decorator because
* we are not going to inject any service into this service.
*
* */
export class LoggingService {
logStatusChanged(status: string) {
console.log("A server status changed, new status: "+ status);
}
}
|
5db73c6341c851c72a1eb65c219f7be91832e12a | TypeScript | michael-dean-haynie/rtmpg | /api/src/utilities/logger.ts | 3.15625 | 3 | import config from '../config';
export class Logger {
private static logLevelMatches(level: LogLevel): boolean {
const levelPriority = LogLevelMapping.get(level) || 0;
const configuredPriority = LogLevelMapping.get(config.app.logLevel) || 0;
return levelPriority <= configuredPriority;
}
private sta... |
9b480566262a0f9f0d93ee879ac069169de6d8be | TypeScript | gungunfebrianza/Belajar-Dengan-Jenius-DenoTheWKWKLand | /src/ch3-subchapter5/check-type/typeof.ts | 3.1875 | 3 | const map1 = new Map();
const array = ["Hi", "Maudy"];
const object1 = {};
function reflect(param: any): any {
return param;
}
console.log(typeof map1);
console.log(typeof array);
console.log(typeof object1);
console.log(typeof reflect(() => {}));
/*
object
object
object
function
*/
|
60ae30365588325961ff468b0c3861aeed66a91e | TypeScript | webdonalds/jmt-server | /src/services/socket.ts | 2.6875 | 3 | import WebSocket from 'ws';
import { Event } from '../events';
import logger from '../logger';
export class SocketService {
private sockets = new Map<string, WebSocket>();
register(clientId: string, socket: WebSocket): void {
logger.info(`socket registered: ${clientId}`);
this.sockets.set(clientId, socke... |
bb22fb1b9e9366e9c7197a38c2fb38e1447a7fe5 | TypeScript | pmdartus/shader-experiments | /shader-preview/src/core/graph/GraphNode.ts | 3.109375 | 3 | import { uuid } from "../../utils/uuid";
import { Vec2 } from "../types";
import Graph from "./Graph";
import Input from "./Input";
import Output from "./Output";
import Property from "./Property";
import Connection from "./Connection";
export default class GraphNode {
id: string;
graph: Graph;
title: string;
... |
4fd5063bc186ad90eb2ec7feb86e06a0266e1953 | TypeScript | gaaoge/GGCat | /src/game/Cat.ts | 2.671875 | 3 | /**
*
* @author GG on 15-06-30
*
*/
module game {
export class Cat extends egret.Sprite {
public node: Node;
private isWeizhu: boolean;
private staymc: egret.MovieClip;
private weizhumc: egret.MovieClip;
public constructor() {
super();
this.staymc ... |
c949e4d557f19c0274855d639d648b9476dddd2b | TypeScript | Skatteetaten/frontend-components | /src/components/OpenClose/OpenClose.types.ts | 2.9375 | 3 | export interface OpenCloseProps {
/** If the content aria should be open/visible */
isOpen?: boolean;
/** Callback when opened (not when closed) */
onClick?: (...args: any[]) => any;
/** Button title */
title?: string;
/** If the title should be a wrapped in a heading tag, value 1-7 .*/
headingLevel?: ... |
3b65dc39d5b9bcd7bc2863c40dc9a712740ffbf4 | TypeScript | dpinol/botonic | /packages/botonic-plugin-contentful/src/util/objects.ts | 3.546875 | 4 | // eslint-disable-next-line @typescript-eslint/ban-types
export function shallowClone<T extends object>(obj: T): T {
if (obj == undefined) {
return obj
}
//https://stackoverflow.com/a/28152032/145289 create copies the methods
const clone = Object.create(obj)
// without copying prototype, some fields (mayb... |
35ca9e9ae07f97a36457fe3ffd63a80084fc1f90 | TypeScript | michaelcoxon/utilities | /src/Enumerators/AggregateEnumerator.spec.ts | 3.328125 | 3 | import { Collection } from '../../src/Enumerables';
import AggregateEnumerator from '../../src/Enumerators/AggregateEnumerator';
import isNumber from '../../src/TypeHelpers/isNumber';
describe("AggregateEnumerator.constructor", () =>
{
it("should return an enumerator from a collection", () =>
{
const ... |
88ec70b8deef0edcfe2023de806c474e5cc968da | TypeScript | danidre14/char | /tests/isControl.test.ts | 2.546875 | 3 | // Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// https://github.com/dotnet/runtime/blob/master/src/libraries/System.Runtime/tests/System/CharTests.cs
import { isControl, UnicodeCategory } from '../src';
import { display, getTest... |
83484bc014ea006b80ab84ee344a095e8a2dcecf | TypeScript | benwainwright/hue-build-status | /client.spec.ts | 2.609375 | 3 | import { HueClient, DEVICE_TYPE } from "./client";
import nock from "nock";
beforeEach(() => {
nock.disableNetConnect();
});
afterEach(() => {
nock.cleanAll();
nock.enableNetConnect();
});
describe("the hue client", () => {
describe("get", () => {
it("if no password is passed in, it gets one from the bri... |
8a6b74c1399b2aa2e9bb6a28a5d7eb5403b09645 | TypeScript | Nikpds/Gamerules | /src/app/order/order.ts | 2.515625 | 3 | export class Filter {
sortOrder: boolean;
sortField: string;
search: string;
searchField: string;
results = 20;
orderStatus: number[];
constructor() {
this.orderStatus = new Array<number>();
}
}
export class FilteredData<T> {
filters: Filter;
data: Array<T>;
construc... |