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 |
|---|---|---|---|---|---|---|
8cdc47a51a44d403594d37cb5d2c313bf43c9efd | TypeScript | laszlokiraly/functional-ts | /src/averageSalary.ts | 3.015625 | 3 | import {Employee} from './employee';
import {Department} from './department';
import {Predicate, and} from './predicate';
import {average} from './util';
function averageSalaryBEFORE(employees: Employee[], minSalary: number, department?: Department): number {
let total = 0;
let count = 0;
employees.forEac... |
215b87dd853ba2d387eefd983723db5e498d3ee3 | TypeScript | supasympa/ts-webpack-monorepo | /components/services/hello-world-service/src/adapters/ExpressRoutes.ts | 2.53125 | 3 | import {Customer, Person} from '@foo/domain';
import * as Express from 'express';
import {HelloWorldService} from '../HelloWorldService';
export interface HelloWorldServiceResponse {
reply: string;
}
export function applyHelloWorldRouteHandlersTo(app: Express.Application): void {
app.post('/hello', (req: Expr... |
de465b73dd3aaa814426181f6126ff4893219f95 | TypeScript | bodekbeska/securityadmin | /src/app/sorter.service.ts | 2.65625 | 3 | import { Injectable } from '@angular/core';
@Injectable()
export class SorterService {
ascdesc : boolean;
constructor() { }
private dynamicSort(property) {
var sortOrder = 1;
if(property[0] === "-") {
sortOrder = -1;
property = property.substr(1);
}
return function (a,b... |
6a1e5602ed34a3abf013ad73569b3e82c52180a6 | TypeScript | MunChanggyun/Muns | /letmeknow/back/src/lib/common.ts | 3.1875 | 3 | export const getDateYYYYMMDD = (addDate: number, addType:string, oriDate:Date) => {
const year = addType === "Y" ? oriDate.getFullYear() + addDate : oriDate.getFullYear();
const month = addType === "M" ? oriDate.getMonth() + 1 + addDate : oriDate.getMonth() + 1;
const day = addType === "M" ? oriDate.getDay(... |
2d7a3aa00ee09a75c61e0404f5e90f677e6bb083 | TypeScript | olivmonnier/composition | /src/String/capitalize.ts | 3.484375 | 3 | /**
* @description
* capitalizes the first letter of a string.
* @example
* capitalize('fooBar'); // 'FooBar'
* capitalize('fooBar', true); // 'Foobar'
*/
export function capitalize([first, ...rest]: string): string {
return first.toUpperCase() + rest.join("");
}
|
98f0283f987226f1db595afafd0c2fae9c72600f | TypeScript | capricorn86/happy-dom | /packages/happy-dom/src/fetch/utilities/FetchBodyUtility.ts | 2.9375 | 3 | import MultipartFormDataParser from '../multipart/MultipartFormDataParser.js';
import Stream from 'stream';
import { URLSearchParams } from 'url';
import FormData from '../../form-data/FormData.js';
import Blob from '../../file/Blob.js';
import DOMException from '../../exception/DOMException.js';
import DOMExceptionNam... |
f0af70f00b2f467a70a2a2500cd3b3742333bb0e | TypeScript | blslade-neumont/turbo-winner | /frontend/src/utils/get-cookie.ts | 2.578125 | 3 |
export function getCookie(name: string): string | null {
let cookieValue = '; ' + document.cookie;
let parts = cookieValue.split(`; ${name}=`);
if (parts.length === 2) return parts[1].split(';')[0];
return null;
}
|
99f5b5497c8745110c0da71b240a0243da35c114 | TypeScript | AeternaEst/Frontend-Experiments | /React/Redux-Saga/src/services/property-service.ts | 2.71875 | 3 | /* eslint-disable max-len */
import { Property } from "../types/property";
import { Comment } from "../types/comment";
import sleep from "../utils/general-utils";
import {
cityNames,
propertyDatabase,
streetNames,
zipCodes,
} from "../data/database";
export default class PropertyService {
getProperties = ():... |
5e1af64040fde31629ac8f7b16568ce8bbb2e3d9 | TypeScript | wesherwo/dynamic-forms | /src/app/services/control.service.ts | 2.53125 | 3 | import { Injectable } from '@angular/core';
import { Dropdown } from '../controls/dropdown';
import { Textbox } from '../controls/textbox';
import { Radio } from '../controls/radio';
import { StarRating } from '../controls/star-rating';
import { ControlBase } from '../controls/control-base';
import { DateRange } from ... |
490b04b6b145facaef09ffdfe28de3e3ae06b54d | TypeScript | MichaelBone/district_council_of_streaky_bay_sa_development_applications | /scraper.ts | 2.9375 | 3 | // Parses the development applications at the South Australian District Council of Streaky Bay web
// site and places them in a database.
//
// Michael Bone
// 15th March 2019
"use strict";
import * as fs from "fs";
import * as cheerio from "cheerio";
import * as request from "request-promise-native";
import * as sql... |
411eb0a27fe303979abb456fba7c43bad0bd5fa7 | TypeScript | benjamim015/WhyHome-api-2.0 | /src/modules/lists/services/RemoveSeriesFromListService.ts | 2.53125 | 3 | import { inject, injectable } from 'tsyringe';
import Series from '@modules/whys/infra/typeorm/entities/Series';
import ISeriesRepository from '@modules/whys/repositories/ISeriesRepository';
import AppError from '@shared/errors/AppError';
import IListsRepository from '../repositories/IListsRepository';
interface IRe... |
0da3b3f57a907cb607b8288b881ce7a81f7ab94b | TypeScript | vikaspotluri123/plant-health-monitor | /components/wrapper/lib/drone-connection.ts | 2.78125 | 3 | import {EventEmitter} from 'events';
import {isIPv4} from 'net';
import ping from './ping';
// @const POLLING_INTERVAL = 15;
const POLLING_INTERVAL = 1;
export class DroneConnection {
public events: EventEmitter = new EventEmitter();
private connectionAddr: string;
private connected = false;
constructor(i... |
0523467e3489d4f0eeb5330e3e55e9734a6bb91d | TypeScript | jsaunie/Restful-api-nodejs-postgresql-typescript | /src/http/controller/UserController.ts | 2.890625 | 3 | import {Request, Response} from 'express';
import {UserInstance} from "../../types/models/User";
import User from "../../database/models/User";
export default class UserController {
/**
* Show all users
* @method GET
* @param {Request} req
* @param {Response} res
* @return void
*/
... |
cb0f9fefc07c6c63f3adde21004399c7cab14b08 | TypeScript | AndrewVdovichenko/battle-city-game | /front/src/game/gameObjects/tree.ts | 2.53125 | 3 | import GameObject from '../gameClasses/gameObject';
import EntitySkins from '../gameEngine/engineModules/constObjects/entitySkins';
class Tree extends GameObject {
size = 50;
constructor(x: number, y: number, type: 'o' | 'a') {
super(x, y);
if (type === 'o') {
this.skin = EntitySki... |
796f1a35bc0e06753d5ff60611fa1f937dc82d50 | TypeScript | doc22940/rough-charts | /packages/react-rough-charts/stories/colors.ts | 2.640625 | 3 | const shuffle = (xs = []) => {
let { length } = xs
while (length > 0) {
const randomIndex = Math.floor(Math.random() * length)
length -= 1
const temp = xs[randomIndex]
xs[randomIndex] = xs[length] // eslint-disable-line
xs[length] = temp // eslint-disable-line
}
return xs
}
export const col... |
a50555b4f83a1ad36fc6795c0ee005acd0c65a92 | TypeScript | yingding/server-ml-examples | /playWithSparkMlExample/webClient/src/app/private/binding-examples/binding-child/binding-child.component.ts | 2.765625 | 3 | import { Component, OnInit, OnChanges, SimpleChange, Input } from '@angular/core';
@Component({
selector: 'app-binding-child',
templateUrl: './binding-child.component.html',
styleUrls: ['./binding-child.component.scss']
})
export class BindingChildComponent implements OnInit, OnChanges {
// Define the propert... |
6359f4614d5611a55f6ec8924bf844699babe84e | TypeScript | psumal/angular-dynamic-forms | /src/app/modules/dynamic-form-addons/payment/sepa/formatter-parser/sepa.service.ts | 2.515625 | 3 |
export class SepaService {
constructor() { }
getCountryFromIban(iban:string):string {
iban = iban || '';
let country = '';
//get char from pos 0 to 2 or less
if (iban.length >= 2) {
country = iban[0] + iban[1];
} else {
country = (iban) ? iban.substring(0, iban.length) : '';
... |
78721ecd8fa985199cc6e3d05ab39bf73deb9294 | TypeScript | winverse/typeorm-sample | /src/entity/Post.ts | 2.609375 | 3 | import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, Index } from 'typeorm';
import User from './User';
@Entity('posts')
export default class Post {
@PrimaryGeneratedColumn('uuid')
id!: string;
@Column({ length: 255 })
title!: string;
@Column('text')
body!: string;
@Column({ length:... |
02d91f5a85a8faa6c0a8c8c4a547dccb40319d58 | TypeScript | green-fox-academy/hojpaat | /week-02/day-03/function-to-center.ts | 3.46875 | 3 | 'use strict';
const canvas = document.querySelector('.main-canvas') as HTMLCanvasElement;
const ctx = canvas.getContext('2d');
// DO NOT TOUCH THE CODE ABOVE THIS LINE
// create a line drawing function that takes 2 parameters:
// The x and y coordinates of the line's starting point
// and draws a line from that poin... |
c9c6621154405f755e0ca564e458e4ac278177eb | TypeScript | denoland/deno | /ext/node/polyfills/_fs/_fs_common.ts | 2.5625 | 3 | // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// TODO(petamoriken): enable prefer-primordials for node polyfills
// deno-lint-ignore-file prefer-primordials
import {
O_APPEND,
O_CREAT,
O_EXCL,
O_RDONLY,
O_RDWR,
O_TRUNC,
O_WRONLY,
} from "ext:deno_node/_fs/_fs_constants.ts";
... |
54a6f9227b8b186b38025588a3d49ed965438276 | TypeScript | gamejolt/gamejolt | /src/_common/content/content-object.ts | 2.84375 | 3 | import { ContentNode } from './content-node';
import { LINK_LENGTH } from './content-rules';
import { MarkObject } from './mark-object';
export type ContentObjectType =
| 'text'
| 'paragraph'
| 'table'
| 'tableRow'
| 'tableCell'
| 'hr'
| 'codeBlock'
| 'gjEmoji'
| 'blockquote'
| 'hardBreak'
| 'embed'
| 'med... |
d4c5d8ee2e7a9a03205b5134d823d07e7eb5ddf7 | TypeScript | aviyot/AssigmentsCourseFullStack | /src/app/assigment-data.ts | 2.671875 | 3 |
export class AssigmentData {
numAssigment: number;
subject: string;
herf: string;
ref: number[] = [];
constructor(numAssigment: number, subject: string, herf: string, ref: number[]) {
this.subject = subject;
this.herf = herf;
this.numAssigment = numAssigment;
this.ref = ref;
}
}
|
21a59e06ff5c0006bf84858f1aa37b2ca5111031 | TypeScript | babel/babel | /packages/babel-helper-create-class-features-plugin/src/fields.ts | 2.625 | 3 | import { template, traverse, types as t } from "@babel/core";
import type { File } from "@babel/core";
import type { NodePath, Visitor, Scope } from "@babel/traverse";
import ReplaceSupers from "@babel/helper-replace-supers";
import environmentVisitor from "@babel/helper-environment-visitor";
import memberExpressionToF... |
4f292f76b1ca7b6675c942c518f89221069c449d | TypeScript | hansellramos/TweetReader | /e2e/src/app.e2e-spec.ts | 2.640625 | 3 | import { AppPage } from './app.po';
import {browser} from 'protractor';
describe('e2e Tests', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
page.navigateTo();
});
browser.ignoreSynchronization = true;
browser.waitForAngularEnabled(false);
/**
* App Component Tests
*/
... |
5ddc775691104f7206a124fa049dc7f067e7c0fd | TypeScript | VladAlmazov/friday | /src/bll/reducer.ts | 2.828125 | 3 | type StateType = {
}
// type ActionsType =
const initState: StateType = {
}
export const reducer = (state: StateType = initState, action: any): StateType => {
switch (action.type) {
case '': {
return state
}
default: {
return state
}
}
}
export const... |
89d78ef914a5beea82d7976aa6331b77913bb020 | TypeScript | qivass/pet | /src/store/ducks/tweet/saga.ts | 2.546875 | 3 | import {call, put, takeLatest} from 'redux-saga/effects'
import { TWEETS_API } from '../../../services/api/tweetsApi';
import { LoadingState } from '../common/constants';
import { Tweet } from '../tweets/contracts/state';
import {FetchTweetDataActionInterface, TweetActions, TweetActionsType} from "./actions";
function... |
0b0c3a44aba7ce7a683149effdf936dd53b1f481 | TypeScript | JimSchofield/julia | /src/index.ts | 2.828125 | 3 | import { CNumber } from "./lib/complex";
import { getComplexNumber, getCoords } from "./lib/coords";
import { doesDiverge } from "./lib/iterate";
import { debounce } from "./lib/util";
let CANVAS_WIDTH = 600;
let CANVAS_HEIGHT = 400;
let MAX_ITER = 1000;
let C = { x: -0.04, y: -0.12 };
const heightInput = document.qu... |
d86f1197d783e3967af30ca09a1259f1364b7491 | TypeScript | theerapatk/pokedex | /pokedex-client/app/components/test/test.component.spec.ts | 2.5625 | 3 | import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TestComponent } from './test.component';
describe('TestComponent', () => {
let component: TestComponent;
let fixture: ComponentFixture<TestComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declaration... |
9ff943236da79ac89c3c9d1d2daef74865e621a8 | TypeScript | pedaars/jina-ui | /packages/jinajs/src/jinaClient.ts | 2.71875 | 3 | import axios, { AxiosInstance } from "axios";
import { serializeRequest, serializeResponse } from "./serializer";
import MockedClient from './MockedClient'
import {
AnyObject,
BaseURL,
RawDocumentData,
RequestSerializer,
ResponseSerializer,
SimpleQueries,
SimpleResults,
} from "./types";
import { OpenAPIV... |
bc8501fb554a643d1ece3d663b67da317580c661 | TypeScript | nutheory/challenges_js | /src/wave.ts | 2.796875 | 3 | export const wave = (str:string) =>
str.split("").map((char, i) =>
char !== " " ?
str.split("").map((ic,idx) =>
ic === char && i === idx ? ic.toUpperCase() : ic
).join("")
: " "
).filter(item => item !== " ") |
4e2db09ddb5446195c1ed5cd6e440ffa648d039f | TypeScript | Juanes-GH/curso-javascript-2019 | /tema6/ejem8/maps.ts | 2.6875 | 3 | {
let properties = {};
properties['email'] = "name@example.com";
let email = properties['email']; //Value has any type
}
{
let properties: any = {};
properties['email'] = "name@example.com";
let email = properties['email']; //Value has any type
}
{
let properties: { [k: string]: ... |
911727f7405d650ca4a5e4bc2a9d98204bdddbc1 | TypeScript | fal-works/p5js-sketches | /lines-of-data/src/common/easing.ts | 3.53125 | 4 | /**
* ---- Common easing utility ------------------------------------------------
*/
import { sq, cubic } from "./math";
/**
* Linear easing function.
* @param ratio
*/
export const easeLinear = (ratio: number): number => ratio;
/**
* easeInQuad.
* @param ratio
*/
export const easeInQuad = sq;
/**
* easeOu... |
c75ef07940ebb47d4958bdf0f5d6423e971ed47e | TypeScript | UriyDR/listOfFilms | /src/app/number.pipe.ts | 3.1875 | 3 | import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'number'
})
export class NumberPipe implements PipeTransform {
transform(number: number = 0): string {
const abs: number = Math.abs(number);
let resultNumber: any;
if (abs >= Math.pow(10, 8)) {
// billion
resultNumber = pars... |
4e27a3edd1368a0f2fcd6ee703bf2feffd7e41ef | TypeScript | fieldyang/nodom3.1 | /extend/defineelementinit.ts | 2.5625 | 3 | import { DefineElement } from "../core/defineelement";
import { DefineElementManager } from "../core/defineelementmanager";
import { NError } from "../core/error";
import { NodomMessage } from "../core/nodom";
import { Element } from "../core/element";
import { Directive } from "../core/directive";
import { Module } fr... |
d9a48d41fce4598ea68b54699aebe826f80f45b6 | TypeScript | hellivan/docker-snapshot-image | /src/lib/docker-utils.ts | 2.515625 | 3 | import axios from 'axios';
import { spawnCmd } from './cmd-utils';
import { BasicCredentials } from './credentials';
async function createDockerImage(tag: string, testMode: boolean, silentDockerMode: boolean): Promise<string> {
const command = 'docker';
const args = ['build', '--force-rm', '-t', tag, './'];
... |
5317f8e4029d5eac8b4626f2e764ba18d84a93dc | TypeScript | zcorky/zodash | /packages/logger/src/format/nginx.ts | 2.703125 | 3 | /**
* Nginx Log Format
*
* log_format main '$remote_addr - $remote_user [$time_local] "$request" '
* '$request_time $request_length '
* '$status $body_bytes_sent "$http_referer" '
* '"$http_user_agent"';
*/
export interface D {
method: string;
path: string;
statu... |
2e943999e683cf372e3efd71dceaa50a96371241 | TypeScript | Hambo3/WebGL | /Instancing/model.ts | 3.09375 | 3 | export type Model = Float32Array;
export function load(path: string): Promise<Array<Model>> {
return fetch(path)
.then((response) => response.arrayBuffer())
.then((buffer) => {
let buffer_array = new Uint16Array(buffer);
let model_data: Array<Model> = [];
let i =... |
92dcfece62ddeaefbd18c1febf2d67691d08b5fb | TypeScript | mzxyz/Mentemia | /src/epics/chainEpic.ts | 2.6875 | 3 | import { of } from 'rxjs';
import R from 'ramda';
import { mergeMap } from 'rxjs/operators';
import { ofType } from 'redux-observable';
import { ActionsObservable } from './types';
const chainEpics = R.curry((fromType: string, toType: string, action$: ActionsObservable) =>
action$.pipe(
ofType(fromType),
mergeMap... |
23212c0497e7acea169a27c35b4940d446af31f9 | TypeScript | aderx/algo_practice | /2021-01/xfu/6.棒球比赛.ts | 3.84375 | 4 | // 682. 棒球比赛
// 你现在是一场采用特殊赛制棒球比赛的记录员。这场比赛由若干回合组成,过去几回合的得分可能会影响以后几回合的得分。
// 比赛开始时,记录是空白的。你会得到一个记录操作的字符串列表 ops,其中 ops[i] 是你需要记录的第 i 项操作,ops 遵循下述规则:
// 整数 x - 表示本回合新获得分数 x
// "+" - 表示本回合新获得的得分是前两次得分的总和。题目数据保证记录此操作时前面总是存在两个有效的分数。
// "D" - 表示本回合新获得的得分是前一次得分的两倍。题目数据保证记录此操作时前面总是存在一个有效的分数。
// "C" - 表示前一次得分无效,将其从记录中移除。题目数据保证记... |
cd5d797db603e4de20f1dec7115a4b8261713f37 | TypeScript | zeng-ge/router-configuration | /src/components/Menu/index.ts | 2.703125 | 3 | import $ from 'jquery'
import { menus } from '../../constants/menu'
import './index.scss'
export default class Menu{
element: JQuery
activeItem: any
onSelectItem: Function
tpl: string = `<ul class="router-menu"></ul>`
constructor(activeItem: string, onSelectItem: Function) {
this.element = $(this.tpl)
... |
cd6e3a04d954b13eeb1f7e021fe1981898272d28 | TypeScript | KUMJC29th/mjc-db-tenho | /src/view_models/grids/ColumnDefinition.ts | 2.671875 | 3 | /* Copyright © 2020 matcher-ice
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
* This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozi... |
56e23a8dd9a358ba8bb06779d36d22bd625d3ea7 | TypeScript | fsicardir/apod | /src/clients/ApodClient.ts | 2.859375 | 3 | import { format } from 'date-fns'
export interface ApodInfo {
title: string,
date: Date,
url: string,
hdurl: string,
explanation: string,
copyright?: string,
}
export interface ApodError {
status: number,
statusMsg: string,
}
const buildRequest = (date: Date): RequestInfo => {
const baseUrl = 'htt... |
683c5684e3e874bca8c73e5d7ede9d38b910ff47 | TypeScript | PriyankaWagh1/root | /ES2015/es62.ts | 3.5 | 4 | //1
console.log('Fibonacci series');
const next = Symbol();
class Fibonacci{
previousNo:number
currentNo:number
value:number
constructor(){
this.previousNo=0;
this.currentNo=1;
}
[next](){
this.value = this.previousNo+this.currentNo
this.previousNo = this.curr... |
11c69ce4942442bdb4029452bae418b76b891e11 | TypeScript | SolAZDev/html2pug | /src/Options.ts | 2.53125 | 3 | /**
* Defines all the options for html2pug.
*/
export interface Options {
caseSensitive: boolean;
collapseBooleanAttributes: boolean;
collapseWhitespace: boolean;
commas: boolean;
doubleQuotes: boolean;
fragment: boolean;
preserveLineBreaks: boolean;
removeEmptyAttributes: boolean;
tabs: boolean;
}
... |
483f2c53e2580b89eed9fee7b170274ca9113526 | TypeScript | f-w/MyGovBC-MSP | /src/app/components/msp/common/birthdate/birthdate.component.ts | 2.515625 | 3 | import {Component, Input, ViewChild, Output, EventEmitter, AfterViewInit, OnInit, ChangeDetectorRef} from '@angular/core'
import {NgForm} from "@angular/forms";
import {Person} from "../../model/person.model";
import {Relationship} from "../../model/status-activities-documents";
import * as moment from 'moment';
requi... |
bc9ebf8403e86c6fb4ce9e0041a48a6357c7586b | TypeScript | Michele9122/PSC | /ClientApp/app/components/newStudent/newStudent.component.ts | 2.609375 | 3 | import { Component } from '@angular/core';
import { Response } from '@angular/http';
import { StudentServices } from '../../services/service';
import { FormGroup, FormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
@Component({
selector: 'new-student',
templateUrl: './newStu... |
81fb4fae4e9097a78b2a151be840bf0fe2eb5b51 | TypeScript | monurakkaya/ionic-capacitor-restaurant-list-example | /src/app/restaurant/models/filter.ts | 2.703125 | 3 | export class Filter {
skip: number;
limit: number;
latitude: number;
longitude: number;
constructor(skip = 0, limit = 10, latitude = 0, longitude = 0) {
Object.assign(this, {skip, limit, latitude, longitude});
}
}
|
4c8ab1c8ffd40f152accbe4501b3617c0451db99 | TypeScript | adamf92/ts-oo-api | /src/framework/abstract.controller.ts | 2.546875 | 3 | import { NextFunction, Request, Response, RequestParamHandler } from "express";
import { ControllerRoute, Route } from "./interface/route.interface";
import { Controllers } from "./controllers";
export abstract class AbstractController {
[key: string]: Function;
abstract routes(): ControllerRoute[];
abst... |
e753995e8622d98b02eb6c117699fffde5ac2f9c | TypeScript | galenscook/algorithms | /javascript/src/sum.ts | 2.515625 | 3 | // Sample file ensuring test setup
export default function sum(firstNum: number, secondNum: number) {
return firstNum + secondNum;
}
|
c1c800b22fc950e112cbd4b8c5a7e82bc9d7bca5 | TypeScript | wgml/aoc-2018-typescript | /src/__tests__/day14.test.ts | 3.125 | 3 | import { first, second } from '../day14';
describe('First', () => {
it('Score after 9 recipes', () => {
const input: string = `9`;
expect(first(input)).toBe('5158916779');
});
});
describe('First', () => {
it('Score after 5 recipes', () => {
const input: string = `5`;
expect(first(input)).toBe('... |
272e69498b78dea7c7ebdcbf9fe239c9b36f4b39 | TypeScript | harlyq/deckmaker | /src/location.ts | 2.859375 | 3 | // Copyright 2014 Reece Elliott
/// <reference path="_dependencies.ts" />
module DeckMaker {
//---------------------------------
export enum LayoutType {
Stack, FanHorizontal, FanVertical, Grid, Row, Column
}
//---------------------------------
export class Location extends Shape {
... |
2868bb925795e1f58ba9084f898651c23e116b3a | TypeScript | liriliri/luna | /src/box-model/index.ts | 2.671875 | 3 | import map from 'licia/map'
import isNum from 'licia/isNum'
import isStr from 'licia/isStr'
import { exportCjs, pxToNum } from '../share/util'
import Component, { IComponentOptions } from '../share/Component'
/** IOptions */
export interface IOptions extends IComponentOptions {
/** Target element. */
element?: HTM... |
2ba3ba132cecb010c16010614c3098b409fab13c | TypeScript | hannesbraun/badenair | /frontend-customers/src/app/services/util/DateUtil.ts | 2.9375 | 3 | const iso8601 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(([+-]\d\d:\d\d)|Z)?$/;
export function convertToDate(body: any) {
if (body === null || body === undefined) {
return body;
}
if (typeof body !== 'object') {
return body;
}
for (const key of Object.keys(body)) {
const ... |
4b09b81f1e09e5f14bc97c4a77303ef2efb442d6 | TypeScript | microsoft/bedrock-cli | /src/lib/traefik/middleware.test.ts | 2.65625 | 3 | import { create } from "./middleware";
describe("TraefikIngressRoute", () => {
test("the right name with service name is created", () => {
const middlewareWithoutRing = create("my-service", "", [
"/home",
"/info",
"/data",
]);
expect(middlewareWithoutRing.metadata.name).toBe("my-service... |
cff98574615b0902650949548753a3fb8e8f504e | TypeScript | silky/refscript | /tests/pos/simple/intersection-00.ts | 3.296875 | 3 |
/*@ foo :: ([Immutable]{ f: ({ string | v = "aaa"})=>string })=>void */
function foo(f: { f: any }) {
}
/*@ x :: [Immutable]
{ f: /\ ({ string | v = "aaa"})=>string
/\ ({ number | v > 0 })=>number
} */
declare var x;
foo(x);
|
2c3101a9c1bdd7c9b990bf75a6782d03d1414a4a | TypeScript | unional/type-plus | /type-plus/ts/nominal/brand.spec.ts | 3.40625 | 3 | import { expect, it } from '@jest/globals'
import { brand, flavor, testType, type Brand } from '../index.js'
it('branded type does not resolve to never', () => {
testType.never<Brand<'test', undefined>>(false)
testType.never<Brand<'test', null>>(false)
testType.never<Brand<'test', boolean>>(false)
testType.never<... |
1be06a2fdcbbda5b908b8d794702903217aed447 | TypeScript | liangjiancang/globalSpeed | /src/utils/migrateSchema.ts | 2.859375 | 3 | import { State } from "../types"
import { getDefaultState } from "../defaults"
import { randomId } from "./helper"
export function migrateGrainData(state: State) {
if (state.version < 7) {
return getDefaultState()
}
if (state.version === 7) {
state = sevenToEight(state)
}
/* if (state.version ... |
0743da63a3e70f1e2be77213ab72d4383eacb7b4 | TypeScript | ShipEngine/connect-sdk | /src/internal/carriers/tracking/tracking-info.ts | 2.546875 | 3 | import { ShipmentStatus, TrackingInfo as TrackingInfoPOJO } from "../../../public";
import { App, DateTimeZone, hideAndFreeze, Joi, _internal } from "../../common";
import { ShipmentIdentifierBase, ShipmentIdentifier } from "../shipments/shipment-identifier";
import { PackageTrackingInfo } from "./package-tracking-info... |
7a8e766365f043ca2a4fbba596d8d8d352a22587 | TypeScript | MissThee/page | /doc/learn-project/typescript-learn-project/ts-learn-doc/c18_decorators/metadataTest.ts | 3.671875 | 4 | import "reflect-metadata";//引入依赖,使编译后的js文件可使用 Reflect.defineMetadata() 等方法
namespace metadataTest {
let target = {a: 1};
//给指定对象设置元数据 metadataValue
Reflect.defineMetadata('metaKey1', "哈哈哈", target);
Reflect.defineMetadata('metaKey2', "嘿嘿嘿", target, "laugh");
//从指定对象获取元数据
console.log(Reflect.get... |
9bc26f160d0ae2eed3facb17256d74594bde95c8 | TypeScript | mjfusa/react-native-windows | /packages/react-native-platform-override/src/UpgradeStrategy.ts | 2.71875 | 3 | /**
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* @format
*/
import GitReactFileRepository from './GitReactFileRepository';
import {OverrideFileRepository} from './FileRepository';
export interface UpgradeResult {
hasConflicts: boolean;
}
/**
* An UpgradeStrategy describes the ... |
4cb0883d799d0c6010d23d74f0501bd57707a0ad | TypeScript | proteus-cpi/openmos-HMI | /src/app/angular/Data/execution-table.ts | 2.71875 | 3 | import { ExecutionTableRow } from './execution-table-row';
export class ExecutionTable {
uniqueId: string;
name: string;
description: string;
rows: ExecutionTableRow[];
registered: Date;
constructor(et: ExecutionTable) {
console.log("loaded execution table: " + JSON.stringify(et));
... |
35aec76a2d371214219c9c30b2fcdf0a8c2209f9 | TypeScript | hyowe/ultravnc_repeater.js | /src/http/test-api-1.ts | 2.515625 | 3 | import {UltraVNCRepeater} from '../index';
import express from 'express';
export interface IConnectedPairItem {
viewerConnectionId: string;
serverConnectionId: string;
}
export interface IViewerConnection {
remoteAddress: string;
vncRemoteIdentity: string;
}
export interface IReverseServerConnection {
remo... |
29c5aabda4e17f51742e91460097d8446a40263b | TypeScript | Buhaiyang/deeplyAssign | /src/utils.ts | 3.015625 | 3 | // const curry = (fn: Function) => {
// const curryN = (n, fn) => (...args: any[]) =>
// args.length >= n
// ? fn(...args)
// : curryN(n-args.length, (...innerArgs) => fn(...args, ...innerArgs))
// // Rest param do not count in function.length
// return curryN(fn.length, fn)
// }
const isShadowNe... |
9d176ae85f01ed1812c57a63b14eaa57471bf9eb | TypeScript | Happy-Creater/SEO-Diagnostic-Warnings-Youtube | /src/app/_inherit/session-storage-handler.ts | 3.046875 | 3 | export abstract class SessionStorageHandler {
constructor() {
this.initSession();
}
/**
* Initialize session.
*/
abstract initSession();
/**
* Save session.
*/
abstract saveSession();
/**
* Get item of session.
* @param key key of session
*/
pr... |
6bd7f98bda337e29e14b00fd5161719e2550ff61 | TypeScript | doc22940/offix | /packages/offix-conflicts-server/src/api/ObjectState.ts | 3.453125 | 3 | import { ObjectStateData } from "./ObjectStateData";
import { ObjectConflictError } from "./ObjectConflictError";
/**
* Interface for handling changing state of the object.
* Implementors can extend this interface to provide reliable way to
* determine if object is in conflict and calculate next state
* (version/h... |
d5eee86149b8a265d55f4cd2dedee2325d95cdf1 | TypeScript | biggyspender/set-operations | /src/index.ts | 3.40625 | 3 | type SubSuperOp = <T>(arrA: T[], arrB: T[]) => boolean;
const isSuperSet: SubSuperOp = (arrA, arrB) => {
const setA = new Set(arrA);
const setB = new Set(arrB);
for (let item of setB) {
if (!setA.has(item)) {
return false
}
}
return true
};
const isSubSet: SubSuperOp = ... |
cd23b7f687489c9972b008b1859d3a4391bd1bb1 | TypeScript | BlunterMonk/Jimbot | /src/commands/helper.ts | 2.625 | 3 | //////////////////////////////////////////
// Author: Dahmitri Stephenson
// Discord: Jimoori#2006
// Jimbot: Discord Bot
//////////////////////////////////////////
import "../util/string-extension.js";
import * as fs from "fs";
import { log, debug, error } from "../global.js";
import { Config } from "../config/config... |
2b2f2eeeae3f8d083ada610fe28b32032776f8f1 | TypeScript | wpilibsuite/wpilib-ws-robot | /src/examples/debug-accelerometer.ts | 2.921875 | 3 | import SimDevice, { FieldDirection } from "../sim-device";
export default class SimAccelerometer extends SimDevice {
private _sensitivity: number = 2;
constructor() {
super("BuiltInAccelerometer");
this.registerField("accelX", FieldDirection.BIDIR, 0); // fieldIdent: <>accelX
this.reg... |
b7ef90341149190ffc59f36e759d1155c987b5a2 | TypeScript | thanhn51/angular_b6_reactive_form_bt1 | /src/app/register/gender.ts | 2.609375 | 3 | export interface Gender {
Male: string;
Female: string;
}
|
bdcc637c779120d5e0a9a937c7b3606d7b1c26c5 | TypeScript | shellywhen/measure-flow | /visualizations/widgets/legend.ts | 2.53125 | 3 | class Legend{
data:any[]
margin={
left:10,
top:20
}
height:number
constructor(data:networkcube.LegendElement[], handlerFunction?:Function){
this.data = data;
}
setClickCallBack(handlerFunction){
this.clickCallBack = handlerFunction;
}
legendEntri... |
8f6b458cad8b35449d4c682d40ca170aca3fd366 | TypeScript | aditya43/typescript | /04-Advanced-Types/06-Function-Overloads.ts | 3.65625 | 4 | type Combinable = string | number;
function add(a: number, b: number): number; // Function overload
function add(a: string, b: string): string; // Function overload
function add(a: number, b: string): string; // Function overload
function add(a: string, b: number): string; // Function overload
function add(a: Combinab... |
a32a42c80afd754ebab7e480212542d9520c5111 | TypeScript | pedromsilvapt/data-async-iterator | /src/errors/dropErrors.ts | 2.625 | 3 | import { AsyncIterableLike, toAsyncIterator } from "../core";
import { safe } from "../transformers/safe";
export function dropErrors<I> ( iterable : AsyncIterableLike<I> ) : AsyncIterable<I> {
return safe( {
[ Symbol.asyncIterator ] () : AsyncIterableIterator<I> {
const iterator = toAsyncItera... |
6ef3286424d2834e6215ea01cc333cf7cab4ecec | TypeScript | rubio41/Recognizers-Text | /JavaScript/packages/recognizers-number/src/number/chinese/parsers.ts | 2.53125 | 3 | import { BaseNumberParser, ParseResult, IParser } from "../parsers";
import { ChineseNumberParserConfiguration } from "./parserConfiguration";
import { Constants } from "../constants";
import { LongFormatType } from "../models";
import { ChineseNumeric } from "../../resources/chineseNumeric";
import { ExtractResult } f... |
d9294c6a1175838969378343bb809b835255662e | TypeScript | yangxin1994/web-components-1 | /packages/field-base/src/delegate-input-state-mixin.d.ts | 2.515625 | 3 | /**
* @license
* Copyright (c) 2021 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { DelegateStateMixin } from './delegate-state-mixin.js';
import { InputMixin } from './input-mixin.js';
import { ValidateMixin } from './validate-mixin.js'... |
7a0d15bb8f56bedde30f8c9c97f20d04fb7d1ce9 | TypeScript | TrigenSoftware/weather | /src/App/services/weather/adapters.ts | 2.578125 | 3 | import {
format
} from 'date-fns';
import {
parseFromTimeZone
} from 'date-fns-timezone';
import WeatherData from '~/models/WeatherData';
export function weatherDataFromResponseData(responseData) {
return WeatherData({
date: formatDate(responseData.dt_txt),
temp: Math.round(responseData.main.t... |
f7dd8a7edd3b1d71665622952f96c92d0300b294 | TypeScript | IdentiTree/app | /backend/src/controllers/areaControllers.ts | 2.703125 | 3 | import { Area } from '../models/Area';
import { User } from '../models/User';
import asyncHandler from "express-async-handler";
import { Request, Response } from 'express';
import { estimateBiomeCarbonCapture } from '../util/treeUtils';
import { biomes as biomesData} from '../data/sampleData/biomeData';
/**
* Get all... |
b6f4f49df67340c4d796cf2d6f355c72de4560ad | TypeScript | ibanjb/pokemon-api | /client/src/redux/reducers/pokemons.ts | 3.109375 | 3 | import * as types from '../types/pokemons';
import IPokemon from '../../interfaces/IPokemon';
interface IState {
list: Array<IPokemon>;
deck: Array<String>;
sortAscending: Boolean;
loading: Boolean;
}
export const initialState: IState = {
list: [],
deck: [],
sortAscending: true,
loading: false,
};
co... |
1a9aa2f4fb8ea7578ba1477c78bafbd38f3731dd | TypeScript | KimHunJin/Study-Book | /algorithm/src/leetcode/LC_2357.ts | 3.28125 | 3 | function minimumOperations(nums: number[]): number {
let result = 0
const sortedArr = [...nums].sort((a,b) => a-b)
for (let i=0;i<sortedArr.length; i++) {
const n = sortedArr[i];
if (n <= 0) {
continue
}
for (let j=i+1; j<sortedArr.length; j++) {
sor... |
8af97472dba46f832f9376466da511bb9f98f8eb | TypeScript | yamacraft/SampRa-android | /firebase/functions/src/index.ts | 2.546875 | 3 | // https://github.com/FirebaseExtended/custom-auth-samples/blob/master/Line/server/app.js
'use strict';
import * as functions from 'firebase-functions';
import { FirebaseError } from 'firebase-admin';
// Modules imports
const rp = require('request-promise');
const express = require('express');
const bodyParser = requ... |
ae29b97b421e28c990653705aa7a33513cd00ec5 | TypeScript | jani-nykanen/unnamed-dungeon-crawler | /src/enemycontainer.ts | 2.703125 | 3 | /**
* Project Island 2021
*
* (c) 2021 Jani Nykänen
*/
class EnemyContainer {
private objects : Array<Enemy>;
private types : Array<Function>;
public readonly maxEnemyTypeIndex : number;
private readonly flyingText : ObjectGenerator<FlyingText>;
private readonly collectibles : ObjectGener... |
a41ee8c11c25c18f9992b7e4f119d8a3d5cc1458 | TypeScript | tobyhinloopen/bonaroo-totp-express | /test/support/testMiddleware.ts | 3.015625 | 3 | import * as express from "express";
import { Request, Response, NextFunction } from "express";
import supertest = require("supertest");
import bodyParser = require("body-parser");
/**
* Test an express middleware by creating an express app & sending a request to
* the app. The `test`-callback is invoked inside a req... |
48c359c8ee9493a47b7547f169d38bf185d8e703 | TypeScript | mikel512/chat-app | /src/app/app.component.ts | 2.5625 | 3 | import { Component, OnInit, AfterViewInit} from '@angular/core';
/*
The @Component decorator specifies the following:
- selector: this specifies how the component will be called within
an HTML file. For this specific component the HTML will look like:
<app-root></app-root>
You can observe this your... |
93e3849ca6a1916b67f85cbcbe155fa9db1c4b7d | TypeScript | paychex/core | /spec/tracker.ts | 2.671875 | 3 | import * as expect from 'expect';
import { set, unset } from 'lodash';
import { spy } from './index';
import { create } from '../trackers/index';
import { withNesting, withReplacement } from '../trackers/utils';
import { NestedStart, NestedTimingTracker, Tracker, TrackingSubscriber } from '../trackers/index';
import { ... |
c6a7682ce02201aab24b8534035fc0a4c3787534 | TypeScript | cockroach54/pyeongchang | /front/src/news/info.service.ts | 2.625 | 3 | import { Injectable } from '@angular/core';
declare var Materialize: any;
@Injectable()
export class InfoService {
static player: string;
static game: string;
static cursor: number = 0; // 현재 뉴스 종류 인덱스. 아래 newsList의 index
static gameKind: string; // 게임 세부종목 ex) 1500m, 5000m
// static newsList: string[] = ['텍... |
5a796b84c98421343fc24eba64b86554ce94d5da | TypeScript | ramyfarid922/knapsack-ts | /tests/packer.spec.ts | 2.703125 | 3 | import { Packer } from "../src/packer"
import * as fs from "fs"
import * as path from "path"
// I used the separate test cases samples to try the pack functions on multiple inputs
// during the test driving
// I have tested the implemenetd algorithm and it passes 3 of the test cases while one of them fails
// I curren... |
cc2d26b85afe0536e5380dc610890483a2d95c0e | TypeScript | gpa/MediaCrawler | /src/util/FileSaver.ts | 2.859375 | 3 | import { writeFile } from 'fs';
import { join } from 'path';
export default class FileSaver {
private path: string;
private fileWritePromises: Promise<void>[];
private writtenFilesCount: number;
public constructor(path: string) {
this.path = path;
}
public async ... |
c0499756ff9c86a97538878210736b1001963e4d | TypeScript | gmalkas/genovesa | /client/ui/timeline/resume.ts | 2.953125 | 3 | /// <reference path="../../definitions/references.d.ts"/>
/// <reference path="./resume-sections.ts"/>
/// <reference path="../iview.ts"/>
/// <reference path="../../template-factory.ts"/>
module Genovesa.UI.Timeline {
/**
* A simple resume for a person that can be embedded into the timeline panel.
*
... |
f3376983f5e2479bde3caaa5a4395b6735c2bb21 | TypeScript | qumeta/GameDevStudyOf3DHtml5 | /StudyDemos/Demo3/SoftEngine.ts | 2.78125 | 3 | /// <reference path="./Math.ts" />
module SoftEngine {
export class Camera {
constructor(public Position = Qumeta.Vector3.Zero(), public Target = Qumeta.Vector3.Zero()) {
}
}
export class Mesh {
public Vertices: Array<Qumeta.Vector3> = [];
public Faces: Array<Qumeta.Vector... |
2f332fa7f523b3e9b68b37f89fd82ea19a4ec34f | TypeScript | vuescape/vuescape | /src/http/Axios.ts | 2.765625 | 3 | import axios, { AxiosAdapter, AxiosInstance, AxiosPromise } from 'axios'
export interface CacheOptions {
maxAgeMinutes: number
maxSize: number
shouldCacheAllRequests: boolean
cacheFlag: string
}
export class Axios {
private static shouldUseCache = false
private static cacheAdapterFactory: () => AxiosAdapt... |
5b66ce28d4f3cac4e48dd8e8cd0fb055bd60a183 | TypeScript | dreamerdihe/ricebook-frontend | /src/app/user.ts | 2.890625 | 3 | export class User {
public accountName: string;
public email: string;
public phoneNumber: string;
public dateOfBirth: string;
public zipcode: string;
public password: string;
public headline?: string;
public displayName?: string;
public portrait?: string;
constructor( accountName: string, email: str... |
0913ac7718288e75271b67caff2d23be20e522f9 | TypeScript | ezzooozz/trellis-app | /src/classes/AsyncInterval.ts | 3.34375 | 3 | type AsyncCallback = (...args: any[]) => PromiseLike<any|void>
class AsyncIntervalInstance {
private timeoutId: number
private args: any[]
private isRunning: boolean = true
/**
* An equivalent function to setInterval, but it waits for any asynchronous operations to complete before starting
* queueing th... |
daf4a39b33a969fb8f8d25ce04a71e3a1a652742 | TypeScript | chrisbtong/app-config-loader | /test/SecretService.test.ts | 2.609375 | 3 | import AzureSecretService from '../src/secretService/AzureSecretService';
import SecretService from '../src/secretService/SecretService';
describe('SecretService.ts', () => {
describe('getSecret', () => {
it('should reject with error if no .env file exist', () => {
const secretService = new SecretSer... |
c8319e09f19ca49d2c31f4c986ca9eb94dd1e7f7 | TypeScript | nervosnetwork/neuron | /packages/neuron-ui/src/tests/validators/tokenName/fixtures.ts | 2.640625 | 3 | import { ErrorCode } from 'utils/enums'
const fixtures = {
'Should throw an error when token name is required but not provided': {
params: {
tokenName: '',
required: true,
isCKB: false,
},
exception: ErrorCode.FieldRequired,
},
'Should pass when token name is not required and not pr... |
b6d0e455b66b079d6dfd3943903325c48d2f3d76 | TypeScript | jeffersonest/express-typescript | /src/helpers/ErrorListHelper.ts | 2.5625 | 3 | import ErrorList from '../interfaces/IErrorList'
class ErrorListHelper {
protected readonly errors: Array<ErrorList> = [
{ code: 0, message: 'success' }
]
public getError (code: number): ErrorList {
return this.errors[code]
}
}
export default new ErrorListHelper()
|
3eb46c954d72f6a1feca60fce958f3fab486b128 | TypeScript | b4dnewz/string-template | /src/index.ts | 3.515625 | 4 | interface IReplacements {
[key: string]: any;
}
interface IFormatOptions {
pattern?: string;
ignoreErrors?: boolean;
}
const wordPattern = "(?!\\.)([a-zA-Z0-9_.]+)(?<!\\.)";
const defaultPattern = "{%s}";
/**
* Gets an object property with dot notation support
*/
function get(object: any, path: string ... |
e38906356fe906083fe711db62103ab16c07689a | TypeScript | EditionsENI/javascript-3e-edition | /ionic3-infos_hardware/src/pages/home/home.ts | 2.703125 | 3 | // Import de classes (système)
import { Component } from '@angular/core';
import { Device } from '@ionic-native/device';
// Décorateur @Component
// Description de la page (composant Angular) :
// - selector = Page SCSS associée au script TypeScript
// - templateUrl = Page HTML associée au script TypeScript
@Component... |
038aebf85bb55c16610ecbd63c5cc17fb834a361 | TypeScript | vitarn/tdv | /test/schema.test.ts | 3.046875 | 3 | import Joi from 'joi'
import { Schema } from '../src/schema'
import { required, optional, reference, createDecorator } from '../src/decorator'
describe('Schema', () => {
describe('Joi', () => {
it('use a copy version Joi', () => {
expect(Schema.Joi).not.toBe(Joi)
})
})
describe... |
afc648b0302aaaa40320fd7af7824ff26365882e | TypeScript | tdrcork/Enterprise-Application-Seed | /src/app/core/permissions/state/permissions.actions.ts | 2.515625 | 3 | import { Action } from '@ngrx/store';
export const SET_USER_CLEARANCE = 'SET_USER_CLEARANCE';
export const SET_USER_KEYS = 'SET_USER_KEYS';
export const ADD_USER_KEY = 'ADD_USER_KEY';
export const DELETE_USER_KEY = 'DELETE_USER_KEY';
export const CLEAR_PERMISSIONS = 'CLEAR_PERMISSIONS';
export class SetUserClearance... |
71dc953af8bb83bcd4f765778f8f93852b855506 | TypeScript | NewEraCodeRepo/sf-datapipeline-lib | /src/logger.ts | 2.859375 | 3 | import * as colors from "colors/safe";
import { format } from "logform";
import * as winston from "winston";
import { Event, IDelivery } from "./index";
const safeStringify = require("fast-safe-stringify");
// keeping for backwards compatibility
export function logEvent(delivery: IDelivery<Event>, topic: string = "") ... |
a4bf2bdd5a5618fdb0a3783bca58b8fe3a6df187 | TypeScript | derrickp/dented-lotus | /src/stores/UserStore.ts | 2.546875 | 3 |
import { User } from "../../common/models/User";
import { PublicUser } from "../../common/responses/PublicUser";
import { UserResponse } from "../../common/responses/UserResponse";
import { Store } from "./Store";
import { saveUserInfo, getUser as serverGetUser, getAllPublicUsers } from "../utilities/server/u... |