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 |
|---|---|---|---|---|---|---|
da0208264926dcade5279af992c0440cb0469065 | TypeScript | jujunjun110/ts-test | /src/js/my_mod.ts | 3.46875 | 3 | export default class MyMod {
message(): string {
return 'hello'
}
extract_number(text: string): number | null {
const res = text.match(/\d{1}/g)
return res === null ? null : parseFloat(res.join(''))
}
fib(num: number): number {
function fib_inner(counter: number, p1: number, p2: number): num... |
4bba5b28b0b5a76248a980b3705720935e24bf81 | TypeScript | ycllz/renderer | /lib/filters/tasks/Filter3DHBlurTask.ts | 2.578125 | 3 | import Image2D = require("awayjs-core/lib/data/Image2D");
import Camera = require("awayjs-display/lib/entities/Camera");
import ContextGLProgramType = require("awayjs-stagegl/lib/base/ContextGLProgramType");
import Stage = require("awayjs-stagegl/lib/base/Stage");
import Filter3DTaskBase = requir... |
01fadfde23c2f3ef297faa12388900af85310fe8 | TypeScript | kyleschaeffer/binary-search | /src/binary-search.ts | 4.03125 | 4 | import { SortedList } from './sorted-list';
/**
* Search a sorted list for an item using binary search algorithm
* - Performant: O(log n)
*/
export function binarySearch<T>(haystack: SortedList<T>, needle: T): number|undefined {
// Initial search params
let min: number = 0;
let max: number = haystack.length ... |
24f6c439a878f5e6c97aed6d47d558433544017d | TypeScript | Denilisium/uzd | /src/renderer/common/utils.ts | 3.09375 | 3 | export function groupBy<T>(array: T[], key: string): { [key: string]: T[] } {
return array.reduce((prev, curr) => {
(prev[curr[key]] = prev[curr[key]] || []).push(curr);
return prev;
}, {});
}
export function orderByDesc<T>(array: T[], key: string): T[] {
return array.sort((a, b) => {
return a[key] -... |
d91797e93c50da71d97b34ece908351d1a9b49fd | TypeScript | panxvpeng1/Learning-TS | /examples/interface/index.ts | 3.78125 | 4 | // //参数接口
// interface labelvalue {
// label:string;
// }
// function printLabel(labelobj:labelvalue){
// console.log(labelobj.label);
// }
// let myobj = {size:100,label:'ppaa'}
// printLabel(myobj);
// //可选属性
// interface squareconfig {
// color?:string;
// width?:number;
// }
// function createsqua... |
b0db4485f61756225a851a9f30dfd71dd0e5ce69 | TypeScript | shubham-kaushal/contember | /packages/engine-content-api/tests/cases/unit/permissionMergerTest.ts | 2.59375 | 3 | import 'jasmine'
import { Acl, Model } from '@contember/schema'
import PermissionFactory from '../../../src/acl/PermissionFactory'
import { SchemaBuilder } from '@contember/schema-definition'
interface Test {
acl: Acl.Schema
roles: string[]
result: Acl.Permissions
}
const execute = (test: Test) => {
const schema:... |
1e4b5a3052480d77c37e5191c9b941cd0a5cd80a | TypeScript | zhaoge1991/oa-front | /src/app/models/work/task/taskType.ts | 2.8125 | 3 | export class TaskType {
task_type_id: number;
name: string;
level: number;
created_at: string;
updated_at: string;
constructor(taskType) {
if (taskType) {
this.task_type_id = taskType.task_type_id;
this.name = taskType.name;
this.level = taskType.level... |
44c6c60f46222ca5aeb811ba64f854d899b706ad | TypeScript | malvdev/angular-google-books-api | /libs/book/domain/src/lib/application/+state/book/book.reducer.ts | 2.65625 | 3 | import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity';
import { createReducer, on, Action } from '@ngrx/store';
import * as BookActions from './book.actions';
import { BookEntity } from '../../../entities';
export const BOOK_FEATURE_KEY = 'book';
export interface BookError {
error: { messa... |
2f4026a56d638a817bc684968a0282f3e483766e | TypeScript | ShashirajSingh/Git-Assignment | /src/controllers/userController.ts | 2.671875 | 3 | import { Request, Response } from 'express';
import userModel from '../models/user.model';
import userService from '../services/user.service';
import responseService from '../services/response.service';
export default class {
static async getUserDetails(req: Request, res: Response) {
try {
const userName: ... |
0cc37bfadea2af5d664b479167a29f57d10cd1a2 | TypeScript | rubykhanhas/techlife-ecommerce | /client/src/app/slices/cartSlice.ts | 3.015625 | 3 | import {createSlice} from '@reduxjs/toolkit'
export type CartItemType = {
imageUrl: string;
amount?: number;
title: string;
_id: string;
color: string;
salePrice: number;
}
type CartSliceActionType = {
type: string;
payload: CartItemType
}
const cache: any = sessionStorage.getItem('ca... |
e9facc7f88f35e247ca49a1efe8c83adb5badc79 | TypeScript | EverCrawl/client | /src/core/ECS.ts | 3.546875 | 4 | import { Constructor, InstanceTypeTuple, TypeOf } from "core/utils";
/**
* An opaque identifier used to access component arrays
*/
export type Entity = number;
/**
* Stores arbitrary data
*/
export type Component = {
free?: () => void;
[x: string]: any;
[x: number]: any;
}
/**
* Smallest logical uni... |
96158a77394e1f7f6f3b4e550c001466297a27f7 | TypeScript | flyFatSeal/react-components | /src/haiwell/Alert/MockAlertService.ts | 2.703125 | 3 | function ranText(prefix: string = "", len: number = 9): string {
let str = prefix;
for (let i = 0; i < len; i++) {
str += String.fromCharCode(Math.floor(Math.random() * 26) | ranOption(0x41, 0x61));
}
return str;
}
function ranOption<T1, T2>(v: T1, v2: T2): T1 | T2 {
return Math.random() >=... |
1763fa22e8a906e296a79c317e68e379983a6eeb | TypeScript | YuhSylphy/motty-derby | /src/features/horse-defs/core/horse.ts | 3.078125 | 3 | import { of } from 'rxjs';
import {
groupBy,
mergeAll,
mergeMap,
toArray,
reduce,
tap,
} from 'rxjs/operators';
export type Sex = 'male' | 'female' | 'unknown';
export type Line =
| 'Uk' // 不明(指定なし)
| 'Ec' // エクリプス系
| 'Ph' // ファラリス系
| 'Ns' // ナスルーラ系
| 'Ro' // ロイヤルチャージャー系
| 'Ne' // ニアークティック系
| 'Na' // ネイテ... |
73e6a01368fac686db153fa42ac3ba8c690a9834 | TypeScript | Jsurapong/compare-purestate-recoil-rxjs | /modules/pureState/service/api.ts | 2.953125 | 3 | import axios from "axios";
interface List {
id: number;
title: string;
author: string;
}
interface Form {
id: number | null;
method: "post" | "put";
data: List;
}
export interface State {
list: List[];
detail: List;
form: Form;
}
const initDetail: List = { id: 0, title: "", author: "" }; // show
... |
6dffc72b493b34efbf37a787588fc0ef14808fc6 | TypeScript | cybernetics/WebRx | /src/Collections/Map.ts | 2.859375 | 3 | /// <reference path="../../node_modules/typescript/lib/lib.es6.d.ts" />
/// <reference path="../Interfaces.ts" />
import { getOid } from "../Core/Oid"
"use strict";
/**
* ES6 Map Shim
* @class
*/
class MapEmulated<TKey extends Object, T> implements wx.IMap<TKey, T> {
////////////////////
/// IMap
public... |
b94fd3abd894e0c1315c040639a4acb45e258af2 | TypeScript | BinaryProvider/react-data-grid | /test/keyboardNavigation.test.ts | 2.546875 | 3 | import userEvent from '@testing-library/user-event';
import { fireEvent } from '@testing-library/react';
import type { Column } from '../src';
import { setup, getSelectedCell, validateCellPosition } from './utils';
type Row = undefined;
const rows: readonly Row[] = Array(100);
const columns: readonly Column<Row>[] =... |
2d95768f4ecc3dcc11a759f8ba618afa19ee32e2 | TypeScript | mostafabita/firebase-ang | /src/app/pipes/abbr.pipe.ts | 2.65625 | 3 | import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'abbr',
})
export class AbbrPipe implements PipeTransform {
transform(value: string, length: number = 2): any {
if (!value) return null;
return value
.split(' ')
.map((str) => str.substr(0, 1))
.join('')
.substr(0, l... |
d0dd217f85b2e8139a2424169bf850954c243cc6 | TypeScript | wlgns2223/booking-light-client | /src/hook/useBookingInput.ts | 2.578125 | 3 | import { arraySum } from "@janda-com/front";
import { useState } from "react";
import {
BookingInput,
CapacityInput,
Fproduct,
FproductBooking,
productList_ProductList_items_ProductBooking,
productList_ProductList_items_ProductBooking_capacityDetails,
productList_ProductList_items_ProductBoo... |
61485c9fbae84a746d2879088a8195719ea6e16b | TypeScript | katawolf/eshop | /src/store/cart/reducer.spec.ts | 2.65625 | 3 | import cartReducer from "./reducer";
import {CartActionType} from "./type";
import {aCartArticle} from "../../data.mock";
describe('reducer spec', () => {
describe('default handle', () => {
test('should return initial state', () => {
expect(
cartReducer(undefined, {} as CartActi... |
e4d82d9fc520883b1b15287e5855755a3bf24c96 | TypeScript | tbilyi/angular-assets-map | /src/app/trucks-list/store/trucks-list.reducer.ts | 2.8125 | 3 | import { Truck } from '../../shared/truck.model';
import * as TrucksListActions from './trucks-list.actions';
export interface State {
trucks: Truck[],
latitude: number,
longitude: number;
}
const initialState: State = {
trucks: [
new Truck(1, 'Truck 1001', 46.968810, 31.957536),
new Truck(2, 'Truck 1... |
7f449b7bdd30e559331f6c3fbd5945660733b45d | TypeScript | Souler/limbus-providers | /src/limbus-provider-kissanimeac/utils/delay.ts | 2.609375 | 3 | export default function delay<T>(time: number, arg?: T) {
return new Promise((resolve) => {
setTimeout(resolve, time, arg);
});
}
|
8ce5f611d9cb1c523b9097fc493890b261bd9e44 | TypeScript | nagyg74poc/wp-promotion-server | /src/interceptors/response-mapper.interceptor.ts | 2.5625 | 3 | import { ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ObjectMapper } from '../mappers/object.mapper';
export interface Response<T> {
data: T;
}
@Injectable()
export class ResponseMapperInterceptor<T> implemen... |
a3fab311d1e51a1579d24aaaab54b80144dc95ce | TypeScript | danielgitk/admin-page | /src/app/input/link/link.component.ts | 2.515625 | 3 | import { Component, Input, OnInit } from '@angular/core';
import { Link } from 'src/app/interfaces';
@Component({
selector: 'input-link',
templateUrl: './link.component.html',
styleUrls: ['./link.component.css']
})
export class LinkComponent implements OnInit {
@Input() defaultValue: false | Link = false;
... |
f0935eb7cd0fcbd5a8f5509414f61839e516ed5b | TypeScript | NJUPT-NYR/SOPT-Frontend | /src/utils/tools.ts | 3.203125 | 3 | /**
* 用户控制MarkdownEditor的编辑历史
*/
export class SizedHistoryState<T = any> {
private values: T[];
private size: number;
private ptr: number;
private listener: any[];
constructor(size: number, init?: T) {
this.values = [];
this.size = size;
this.ptr = 0;
this.listener = [];
if (init) {
... |
8be33dbb07c276c26f8a7dfeba41de71c93aa983 | TypeScript | 13club/13club.github.io | /codeCu/web_admin_main/src/store/modules/admin.ts | 2.5625 | 3 | // import api from 'api/ader'
interface breadCrumbM{
path:string
title:string
}
interface stateM{
breadCrumb: object[] // 面包屑导航,
active:string //当前活动页
}
// initial state
const state:stateM = {
breadCrumb: [],
active:'',
}
// getters
const getters = {
breadC... |
017ffb76c4d3c972ccc82d071545a59ab488abc8 | TypeScript | june2/banking-app | /api-server-node-typescript/src/api/user/user.service.ts | 2.640625 | 3 | import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { UpdateResult, DeleteResult } from 'typeorm';
import { User } from './user.entity';
import { UserRepository } from './user.repository';
import { CreateUserDto, UpdateUserDto } from './user.dto'
@Injectable()
expor... |
af21ca8946df49a2e769498b42792d693a999389 | TypeScript | CN-Shopkeeper/vue3-ts-cms | /src/service/request/config.ts | 2.515625 | 3 | // 1.手动修改
// 2.根据process.env.NODE_ENV
// 开发环境:development
// 生产环境:production
// 测试环境:test
let BASE_URL = "";
const TIME_OUT = 10000;
if (process.env.NODE_ENV === "development") {
BASE_URL = "/api";
} else if (process.env.NODE_ENV === "production") {
BASE_URL = "http://152.136.185.210:5000";
} else {
BASE_URL = ... |
25d272630505a49c522e3bc241c8a992bb91add1 | TypeScript | nrfm/umbrella | /packages/shader-ast-stdlib/src/sdf/plane.ts | 2.828125 | 3 | import { defn, ret } from "@thi.ng/shader-ast/ast/function";
import { add } from "@thi.ng/shader-ast/ast/ops";
import { dot } from "@thi.ng/shader-ast/builtin/math";
/**
* Returns signed distance from `p` to plane defined by `normal` and `w`.
*
* @param p - vec2
* @param normal - vec2
* @param w - float
*/
expor... |
04904cbbdb107af7ca0296f935bb98a1ab5e549f | TypeScript | DNSLV-PMTKV/TravelProject-web | /src/redux/users/userReducer.ts | 3.03125 | 3 | import { setAuthenticated, SET_AUTHENTICATED } from './userActions';
export interface UserState {
isAuthenticated: boolean;
}
export const InitialState: UserState = {
isAuthenticated: false
};
type Action = setAuthenticated;
export const userReducer = (state: UserState = InitialState, action: Action): UserS... |
71086811fa05182980179346ba4e23c9f78311c4 | TypeScript | PHPCraftdream/ReactTypescriptReduxSassChallenge | /src/Core/Types.ts | 2.765625 | 3 | import { FetchError } from "node-fetch";
import { DetailedHTMLProps, InputHTMLAttributes } from "react";
type TReactRenderA = React.ReactElement<any, string | React.JSXElementConstructor<any>>;
type TReactRenderB = React.ReactNodeArray | React.ReactPortal | React.ReactFragment;
export type TRender = TReactRenderA | T... |
10fc13c3fd5e4161d725d237555a212349eec25c | TypeScript | EduardQV/charge-point-app | /test/services/charge-point.service.spec.ts | 2.703125 | 3 | import { CallbackError, Query } from 'mongoose';
import ChargePoint, { IChargePoint, IStatus } from '../../src/api/models/charge-point.model';
import ChargePointService from '../../src/api/services/charge-point.service';
describe('Unit test for ChargePointService', () => {
const service = new ChargePointService();
... |
04c3c82f7bf12cf16af22546b6788b9016b7d705 | TypeScript | swc-project/swc | /crates/swc_bundler/tests/.cache/deno/f6b67896830a42fe1517a5f9c1bc677006d5472e.ts | 3.5 | 4 | // Loaded from https://deno.land/x/ramda@v0.27.2/source/invoker.js
import _curry2 from './internal/_curry2.js';
import _isFunction from './internal/_isFunction.js';
import curryN from './curryN.js';
import toString from './toString.js';
/**
* Turns a named method with a specified arity into a function that can be
... |
033211f9753b38569b0cbdbc08c246460f0af5e7 | TypeScript | iraamaro/vtex-node-sdk | /src/utils/VtexHttpResponse.ts | 2.921875 | 3 | import { IncomingHttpHeaders } from "http";
export class VtexHttpResponse<T = any> {
/**
* Response status
*/
readonly status: number;
/**
* Response body
*/
readonly body: T;
/**
* Response headers
*/
readonly headers: IncomingHttpHeaders;
/**
* @param {number} status
* @param... |
62aaf7229f13f397c1d2f4e8bfb61ac942f26bad | TypeScript | vibrunazo/gengarbobo | /src/app/shared/minmax.directive.ts | 2.625 | 3 | import { Attribute, Directive, forwardRef, Input, OnChanges, SimpleChanges, Provider, NgModule } from '@angular/core';
import { AbstractControl, NG_VALIDATORS, Validator, ValidatorFn, FormControl } from '@angular/forms';
export const MIN_VALUE_VALIDATOR: any = {
provide: NG_VALIDATORS,
// tslint:disable-next-line:... |
c87dec02a0a8e456969ce947ca69d60e1571490b | TypeScript | green-fox-academy/alexfrenkel92 | /week-04/4. nap/anagram.ts | 3.3125 | 3 | 'use strict';
export function anagram (word1: string, word2: string) {
if (word1.split('').sort() !== word2.split('').sort()) {
console.log('Lucky boyyyy, it is an anagram!');
} else {
console.log('You are out of luck, it is not an anagram.');
}
}
anagram('alex', 'lexa'); |
343edcd14d7be22eb8c621bcd2307ac0425c1873 | TypeScript | brooksbecton/cah | /client/src/game/utils/getRandomInt.ts | 3.328125 | 3 | /**
* Returns a random integer below the max provided
*/
function getRandomInt(max = 0) {
if (max !== 0) {
return Math.floor(Math.random() * Math.floor(max));
} else {
throw new Error(`Error: ${max} passed to getRandomInt`);
}
}
export default getRandomInt;
|
b8a92b6593d81886129962ab87d942f29f102c68 | TypeScript | wt2209/qingwu-apartment | /src/pages/living/rooms/data.d.ts | 2.671875 | 3 | export interface RoomListItem {
id: number;
roomName: string;
building: string;
unit: string;
rent: number; // 房间的默认租金,如承包商公寓的房间租金。入住时,可使用此租金,也可自定义新租金
number: number; // 最大人数
remark: string; // 房间备注
status?: 'show' | 'hide'; // 是否在主页面中显示
}
export interface RoomFormValueType {
id: number;
roomName: ... |
2b654c977f98f2cd9ff84803978d16fc246e882a | TypeScript | JakeStanger/ts-docs | /src/searchData.ts | 2.9375 | 3 | import { ClassProperty, Project } from "@ts-docs/extractor";
import fs from "fs";
import { getComment } from "./utils";
/**
* Used for the [[packSearchData]] function.
*/
export const enum ClassMemberFlags {
IS_GETTER = 1 << 0,
IS_SETTER = 1 << 1,
IS_PRIVATE = 1 << 2
}
function buildBitfield(...bits: A... |
d3d5b9ae8801101c3bd356572f28d4172bae9587 | TypeScript | vladimir-ivanov/ngrx-store-example | /src/app/shared/error-overlay/reducers/error-overlay.reducer.ts | 2.734375 | 3 | import {APP_ERROR} from "../errror-overlay.actions";
export interface State {
errorMessage: string;
}
export const initialState: State = {
errorMessage: ''
};
export function reducer(state = initialState,
action: any): State {
switch (action.type) {
case APP_ERROR: {
return {
... |
dc75fc9791bfebcae7c26db1609841db6b864b09 | TypeScript | FeldmanMatan/FinalProject | /src/app/services/window-day-off.service.ts | 2.578125 | 3 | // import { Injectable } from '@angular/core';
// @Injectable({
// providedIn: 'root'
// })
// export class WindowDayOffService {
// constructor() { }
// }
import { Injectable } from "@angular/core";
@Injectable({
providedIn: "root"
})
export class WindowsDaysOffService {
windows_importance: number = 3;
w... |
d1e4a99d9bdd6f447762f7fce1f0b13b56ff9a0c | TypeScript | anshnagrath/ionic-recepieapp | /src/services/shopping-list.ts | 2.609375 | 3 | import { Ingridents } from '../models/ingrident';
export class ShoppingListService {
private ingridents: Ingridents[] = [];
addItem(name: string, amount: number) {
this.ingridents.push(new Ingridents(name, amount));
}
addItems(items: Ingridents[]) {
this.ingridents.push(...items);
}... |
3aca1555f28a7c93c4a2385dc0ca6b836fa24b2b | TypeScript | fabremx/gameru | /src/objects/dialogBox.ts | 2.96875 | 3 | import { IDialogConstructor } from "../interfaces/text.interface";
export default class DialogBox {
private box: Phaser.GameObjects.Rectangle;
private scene: Phaser.Scene;
private dialogs: string[];
private currentText: Phaser.GameObjects.Text;
/** Variables when reading dialogs */
private le... |
448ed6be535f962dbf0374c66d434a68f5811505 | TypeScript | dshubhadeep/veza | /src/lib/Util/Header.ts | 3.140625 | 3 | function getBytes(number: number) {
const result = [];
while (number >= 1) {
result.unshift(Math.floor(number) % 0xff);
number /= 0xff;
}
return result;
}
function parseBytes(bytes: number[]) {
let number = 0;
let n = 1;
for (let i = bytes.length - 1; i >= 0; i--) {
number += bytes[i] * n;
n *= 0xff;
... |
1bfdcd09fa6790b295656c2e0874fcd882896668 | TypeScript | YalongYan/scan-statistics | /dist/index.d.ts | 2.71875 | 3 | interface propTypes {
email: string;
userName: string;
requestUrl?: string;
browserUrl: string;
env: string;
platform: string;
}
/**
*
* @param obj 请求的参数 包含 email、userName、requestUrl、browserUrl、env、platform; 其中 requestUrl 非必传,其他都是必传的
* @param url 请求要使用的接口地址,默认是本地的服务地址
* @returns
*/
declare ... |
42f944270235e660768c40bd66aeebdaa3196b8c | TypeScript | Pasakinskas/book-app | /src/models/userModel.ts | 2.734375 | 3 | import mongoose from "mongoose";
import validator from "validator";
export interface User extends mongoose.Document {
email: string;
password: string;
}
const schema = new mongoose.Schema({
email: {
type: String,
required: true,
unique: true,
validate: (value: string) => {
... |
ebd76b385c601be7353d1573c50305c9a2a09bed | TypeScript | yingshaoxo/Let-s-become-a-master-of-Vue3 | /src/functions.ts | 2.671875 | 3 | import { reactive } from "vue";
export const doesTheyTwoEqual = (a: any, b: any) => {
return a === b
}
export const theGlobalReactiveObject = reactive({
data: {
mood: "",
},
functions: {
changeTheMood: (mood: string) => {
theGlobalReactiveObject.data.mood = mood
},
... |
d8459266c629f90a36a84454d4d0d3ab87c80448 | TypeScript | rooneyshuman/Battlecode | /src/Nav.ts | 2.59375 | 3 | import { availableLoc, manhatDist, horizontalFlip, simplePathFinder } from "./utils";
export function checkerBoardMovement(self: any) {
const formation: number[][] =
[[-1, -1],
[1, -1],
[1, 1],
[-1, 1]];
if (self.checkerBoardSpot === undefined) {
self.checkerBoardSpot =... |
27ed74e88c110ee7470c5a467825e73c90198e2c | TypeScript | knidhi/ibm | /day2/src/step2.ts | 3.203125 | 3 | function addPower(pow:number){
return function(targetClass:any){
return class {
title = new targetClass().title;
power = pow
}
}
}
@addPower(5)
class Batman{
title = "Batman"
};
console.log(new Batman()); |
1a269418501d50bc3c466b75da14d1429c0400c3 | TypeScript | Ajax-7/few300-apr-2020 | /src/app/features/game/actions/game.actions.ts | 2.515625 | 3 | import { createAction, props } from '@ngrx/store';
// this.store.dispatch(gameStarted())
export const gameStarted = createAction(
'[game] game started',
() => ({
randomNumber: Math.floor(Math.random() * 10) + 1 // stolen from Tom Gannaway
})
);
// this.store.dispatch(tookAGuess({ guess }))
export const tookA... |
b049f70330f8dba3ffe691c46d3ee263f643cbfb | TypeScript | nikbelikov/tsp-solver | /demo/index.ts | 2.734375 | 3 | import TSPSolver from "../src/index";
import { IChromosomeWithFitness } from "../src/models/Chromosome";
const ready = () => {
const points = [
{ id: 0, name: "Praha" },
{ id: 1, name: "Paris" },
{ id: 2, name: "Rennes" },
{ id: 3, name: "Amsterdam" },
{ id: 4, name: "Hamburg" },
{ id: 5, nam... |
935bac5149026a6720540ceed551b344f7fa8a7f | TypeScript | aleweichandt/fitx | /src/user/model/reducer.ts | 2.703125 | 3 | import {createReducer} from '../../redux-helpers';
import {
LoadUserData,
LOAD_USER_DATA,
SetMetrics,
SetUsername,
SET_METRICS,
SET_USERNAME,
} from './actions';
import {State, User, UserMetrics} from './types';
export const initialState: State = {
loggedUser: undefined,
};
export const handleLoadUserDa... |
8d36f80ee4d4e3b739d6ee260061d0af326d4cfd | TypeScript | guygoool/BillingApp | /backend/src/controllers/customerController.ts | 2.6875 | 3 | import { Response, Request } from "express"
import Customer from "../models/customerModel"
import { ICustomer } from "../types/customerType"
const addCustomer = async (req: Request, res: Response): Promise<void> => {
try {
const body = req.body as ICustomer
const customer: ICustomer = new Customer... |
e4ad52dbb127565d7e6de85ea7c7ccb4f07074de | TypeScript | sawsenFattahi/nest-crud | /src/auth/user.service.ts | 2.65625 | 3 | import {
HttpException,
HttpStatus,
Injectable,
InternalServerErrorException,
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Observable, from } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
import { Repository } from 'typeorm';
import { User } from './enti... |
3219c23fda6f31fff2adca4d6df8bfda4a6dcef8 | TypeScript | krry/commonplace-foamy-nextjs | /lib/cache.ts | 2.671875 | 3 | /*
* cache for search
* following [@matswainson's lead](https://medium.com/@matswainson/building-a-search-component-for-your-next-js-markdown-blog-9e75e0e7d210)
*/
import fs from 'fs'
import path from 'path'
import read from 'fs-readdir-recursive'
import matter from 'gray-matter'
function getNotes() {
const notes... |
fb711d3aa1e9181ef4bc437a0ad59b11d756de3d | TypeScript | makasuapp/web-portal | /src/app/models/order.ts | 2.734375 | 3 | export type OrderType = 'delivery' | 'pickup'
export type OrderState = 'new' | 'started' | 'done' | 'delivered'
export interface Customer {
id: number
email?: string
name?: string
phone_number?: string
}
export interface OrderItem {
id: number
recipe_id: number
price_cents: number
quantity: number
... |
daf42c3f2fdce7cc2d257df4379a29b577d3c557 | TypeScript | huan/mike-bo | /src/chatgpt/on-message.ts | 2.609375 | 3 | import type { Wechaty, Message } from 'wechaty'
import { ChatGPTAPIBuilder } from './chatgpt-api-builder.js'
const chatGptApi = await ChatGPTAPIBuilder()
const DEFAULT_CREDIT = 1
const MAX_PREMIUM_NUM_NOTICE = '发个红包热闹一下吧!'
const credits = {} as Record<string, number>
export async function onMessage (this: Wechaty, ... |
7d80c4d8199ca2a5b815765718a940612bb9da3e | TypeScript | altriayu/release_log_crawler | /src/utils/chrome/getChromeLogUrl.ts | 2.671875 | 3 | import * as superagent from "superagent"
/**
* 该函数通过输入一个chrome浏览器的版本号,来获取对应版本的更新日志所在的url
* @param version 需要获取的更新日志的版本号
* @returns 更新日志的URL
*/
export const getChromeUrl = async (version: string): Promise<string | any> => {
const getBlogListUrl: string = 'https://0ppzv3ey55-dsn.algolia.net/1/indexes/prod_develope... |
45bd0e1f0c7e3c68379e810fdba9a66e93ac7e1d | TypeScript | future4code/Yuzo-Okamoto | /semana-19/aula-1/tests/1.test.ts | 2.953125 | 3 | import { performPurchase, User } from '../src/exercises/1'
describe("Testing function performPurchase from exercise 1", () => {
test("Must return the updated user if purchase value is lesser than user's balance", () => {
const user = new User("John Doe", 1000);
const output = performPurchase(user, 250);
... |
29d839b4d23fdf655c060e41adb740c386cf4890 | TypeScript | thrashr888/monkey-typescript | /evaluator/builtins/file_realpath.ts | 3.03125 | 3 | import OObject, { Builtin, STRING_OBJ, OBoolean, OString } from '../../object/object';
import { newError } from '../evaluator';
import Environment from '../../object/environment';
import fs from 'fs';
// gets the real path of a given path (resolves `.` and `..`)
// file_realpath('./tmp')
// file_realpath('../sibling/b... |
e22b10b00a89576469614820ac8a886452f24410 | TypeScript | njcodemonster/csvmatchingelectronangular4 | /src/app/app.component.ts | 2.515625 | 3 | import { Component } from '@angular/core';
import {ElectronService} from 'ngx-electron';
//import fs = require('fs');
//
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
msg = 'Reading FTP data in back ground Please enter ... |
8f03cc001d360c98655db98e2c6e8f9c9e5a6925 | TypeScript | Ithomiroff/pane-no-paine | /src/module/classes/separator.ts | 2.609375 | 3 | import { ISeparatorParams } from '../intefaces/separator-params';
import { AbstractElement } from './abstract-element';
export class Separator extends AbstractElement<ISeparatorParams> {
private _hold: boolean = false;
get hold(): boolean {
return this._hold;
}
set hold(value: boolean) {
... |
5b3e6a0279ab37136c85a981e9afa6b209768a70 | TypeScript | MohammedFaragallah/me | /src/Store/Reducers/Locale/reducer.ts | 2.71875 | 3 | import { ActionTypes, LocaleActions, LocaleState } from 'Store';
import {
DefaultLanguage,
getLocale,
getTranslatedMessages,
} from 'localization';
const locale = getLocale(DefaultLanguage.code);
const initialState: LocaleState = {
locale,
messages: getTranslatedMessages(locale.code),
preferredLanguage: undefin... |
5fb8dc52097317e4c98044e485122f701f851bb0 | TypeScript | liphe/delisp | /packages/delisp-core/__tests__/reader.ts | 3.078125 | 3 | import { readAllFromString, readFromString } from "../src/reader";
import { ASExpr } from "../src/sexpr";
function removeLocation(x: ASExpr): object {
switch (x.tag) {
case "number":
case "symbol":
case "string": {
const { location: _, ...props } = x;
return props;
}
case "list":
... |
d065583aeaa91bda9a73c7b7773426e92ba3ef04 | TypeScript | luomus/laji | /projects/laji/src/app/shared/pipe/label.pipe.ts | 2.703125 | 3 | import { concatMap, map, switchMap, toArray } from 'rxjs/operators';
import { Observable, from, of, Subscription } from 'rxjs';
import { ChangeDetectorRef, Pipe, PipeTransform, OnDestroy } from '@angular/core';
import { WarehouseValueMappingService } from '../service/warehouse-value-mapping.service';
import { Translate... |
aaf7d2bef7b8ce54bc92d265a350a69ec6f1b485 | TypeScript | EmmanuelMat/clients-api | /src/core/interfaes/IRequestHandler.ts | 2.75 | 3 | export interface IRequestHandler<TRequest, TResponse> {
task(request: TRequest): TResponse
} |
50f5d57c6bd875212f36c2d911f71b1559c163e0 | TypeScript | kevincar/TRProject | /src/objects/SheetRecordDictionary.ts | 3.25 | 3 | /*
* Filename: SheetRecordDictionary.ts
* Author: Kevin Davis
*
* Description
* A Custom SheetObjectDictionary to properly handle the formula strings
* that TRRecord classes need
*/
class SheetRecordDictionary extends SheetObjectDictionary<TRRecord> {
constructor(sheet: Sheet) {
super(TRRecord, sheet);
}
... |
584fa66053dcc9e7678d73c0f56498ed46824b2e | TypeScript | Coffeekraken/coffeekraken | /packages/tools/sugar/src/js/filter/SSvgFilter.ts | 2.921875 | 3 | // @ts-nocheck
import __uniqid from '../../js/string/uniqid.js';
/**
* @name __SSvgFilter
* @namespace js.filter
* @type Class
* @platform js
* @status wip
*
* This class allows you to create with ease some complexe SVG filters and to apply it on any HTMLEl... |
26e16b9cb0a0cd29b2730f43f2601ce5efdadf67 | TypeScript | penge/expenses-tracker | /src/api/categories.ts | 3.078125 | 3 | const categoriesKey = (email: string) => `categories.${email}`;
export function getCategories(email: string) {
const key = categoriesKey(email);
const categories = (JSON.parse(localStorage.getItem(key) as string) || []) as string[];
return categories;
}
function setCategories(email: string, categories: string[]... |
7365dde2117dade973fa747481cf40de43831a21 | TypeScript | KeithMarex/VvE-APP | /WebApp/src/app/calendar-overview/calendar/calendar.service.ts | 2.640625 | 3 | import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { addMonths, isSameMinute, isSameMonth, subMonths } from 'date-fns';
import { CalendarItem } from '../../../shared/models/calendar-item';
import { CustomEvent } from './custom-event';
import { CalendarDao } from '../../../shared/... |
ef6d0aeda644ff19c751d52d8a420e33e5bfb292 | TypeScript | mariacki/tomb-racer | /back-end/src/game/events/PlayerHitEvent.ts | 2.734375 | 3 | import { PlayerHit, EventType } from "../../../../common";
export class PlayerHitEvent implements PlayerHit
{
isError: boolean = false;
type: EventType = EventType.PLAYER_HIT;
origin: string;
userId: string;
hpTaken: number;
currentHp: number;
constructor(
gameId: string,
... |
82a8cfd5bd9b09346f6eb69da76039076045b664 | TypeScript | Sciator/knapsack-approximation-algorithms | /src/utils/random.ts | 3.34375 | 3 | import { range } from "./array";
export const randInt: {
(maxExcluded: number): number;
(minIncluded: number, maxExcluded: number): number;
} = (a: number, b?: number): number => {
if (b === undefined)
return Math.floor(Math.random() * a);
else
return Math.floor(Math.random() * (b - a)) + a;
};
export... |
d2a55d5b458aaa9a2f443f7ca988eb967a8e13e4 | TypeScript | c4bo3l/omnilytics | /src/hooks/useNumericGenerator.ts | 3.03125 | 3 | export const useNumericGenerator = () => {
const multiplier = [1, 10, 100, 1000, 10000, 100000];
const getRandomIntInRange = (min: number, max: number) => {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
};
const getRandomInteger = (length?: ... |
49c9e0a2f9aee3a159df05b504fafe323963f5e7 | TypeScript | baikinjo/TickitShop | /app/tickit-shop.ts | 3.375 | 3 | const LEGENDARY = 'ping-pong paddle'
const CONJURED = 'conjured'
const CHEESE = 'sharp cheddar'
const TICKET = 'lady gaga ticket'
const NORMAL = 'normal'
export class Item {
name: string
sellIn: number
quality: number
constructor(name: string, sellIn: number, quality: number) {
this.name = name
this.s... |
22bab6058a3900ccfa8c305c20f635e7af2cbfb9 | TypeScript | lazerwalker/closed-captions-app | /src/webrtc.ts | 2.65625 | 3 | import {
sendWebRTCConnectionOffer,
sendWebRTCConnectionAnswer,
sendIceCandidate,
} from "./signalR";
const connections: { [userId: string]: RTCPeerConnection } = {};
const iceServers = { iceServers: [{ urls: "stun:stun.l.google.com:19302" }] };
export async function initiateWebRTCConnection(
userId: string,... |
802100eea75ba0b87c843dc56db8b6614fd6ef6c | TypeScript | LLLLLamHo/zzc-design-mobile | /components/Calendar/util/createPickerData.ts | 2.703125 | 3 | import {selectTimeInterface} from '../propsType';
import { PickerData, ListData } from '../../Picker/propsType';
import { isString } from '../../_util/typeof';
export default function createPickerData(timeRange, minutesInterval: number, currStartTime: selectTimeInterface, currEndTime: selectTimeInterface, defaultStart... |
55ec99613093292c78a7217c0360bd8f33d18b30 | TypeScript | CodingSpiderFox/pantry_party | /src/app/utilities/arrayMove.ts | 3.140625 | 3 | export function arrayMove<T>(arr: T[], oldIndex: number, newIndex: number): T[] {
arr = [...arr];
if (newIndex >= arr.length) {
let k = newIndex - arr.length + 1;
while (k--) {
arr.push(undefined);
}
}
arr.splice(newIndex, 0, arr.splice(oldIndex, 1)[0]);
retur... |
4a048d91249143538e78587309f186d08960f385 | TypeScript | krzowski/zaiste_umbrella | /apps/zaiste_web/assets/js/components/wallet/interfaces.ts | 2.59375 | 3 | export interface DatesRange {
startDate: Date
endDate: Date
}
export interface TransactionsFilters {
showIncomes: boolean
showExpenses: boolean
}
export interface TransactionItem {
id: number
name: string
amount: string
}
export interface Transaction {
id: number
name: string
date: string
incom... |
c5190c1684ba4bf995f1e9c2d100b22644d2d9ec | TypeScript | Synthetixio/kwenta | /hooks/useDebouncedMemo.ts | 2.53125 | 3 | import { useState, useEffect, DependencyList, useCallback } from 'react';
import debounce from 'lodash/debounce';
// source: https://github.com/SevenOutman/use-debounced-memo
export function useDebouncedMemo<T>(
factory: () => T,
deps: DependencyList | undefined,
debounceMs: number
): T {
const [state, setState] ... |
0b0a7dfcaf1a889ce2449f73117560d1ed2e5f91 | TypeScript | karifrederiksen/ordered-collections | /dist/util.d.ts | 2.796875 | 3 | export declare function numberLT(l: number, r: number): boolean;
export declare function stringLT(l: string, r: string): boolean;
export declare type LessThan<a> = (key: a, otherKey: a) => boolean;
export declare function compareNumber(l: number, r: number): number;
export declare function compareString(l: string, r: s... |
2b0a1fb158e6009c6f4f51af02734d239c005e7d | TypeScript | liming/lambda_dynamodb_demo | /src/libs/middleware.ts | 2.578125 | 3 | /**
* The file defines some useful middlewares
*/
import middy from "@middy/core"
import middyJsonBodyParser from "@middy/http-json-body-parser"
/**
*
* @param handler a lambda function which can be "middified"
* @returns
*/
export const middyfy = (handler) => {
// middyJsonBodyParser is to parse event body... |
17424640c96c2d4efd4e7d72ea01935dffbb4925 | TypeScript | ejhayes/graphql-find-options | /sample/src/common/dto/paginated-request.ts | 2.515625 | 3 | import { Field, Int, ArgsType } from '@nestjs/graphql';
import { Type } from 'class-transformer';
import { ClassType } from 'class-transformer/ClassTransformer';
export default function PaginatedRequest<TWhere, TOrder>(TFilterClass: ClassType<TWhere>, TOrderClass: ClassType<TOrder>) {
@ArgsType()
abstract class Pa... |
86ea3533c109521a073ed3a3108472804684928a | TypeScript | luchaohai/typescript-review | /BasicTypes/demo2.ts | 4.21875 | 4 | // TODO 初级「基础类型」
// let arr1:number []= [1,2,3]
// let arr2:(number|string)[] = [1, "str", '123']
// let arr3:Array<number|null> = [null, 123]
// let arr4:any[] = [123, 'string', false]
// TODO 中级「自定义类型」
// 类自定义类型[初级]
// class Person {
// name:string
// constructor(name:string) {
// this.name = name
// }... |
806f0dcc66a292ee6703ee8f102cb49043935cd3 | TypeScript | Wangpengli0419/yg_league | /client/src/game/view/panel/scene/core/BattleCheck.ts | 3 | 3 | /**
* 前后端数据检测方法(有些属性客户端,服务器端的定义不同)
* Created by hh on 2016/11/30.
*/
module fight{
export function check(clientObj, serverObj) {
let result = true;
if (!clientObj || !serverObj || clientObj.length == 0 || serverObj.length == 0) {
return result;
}
let clientArr = client... |
71214e94c7e02f00659c6b71a0eaf9772bc7141f | TypeScript | grimsi/website | /script/services/BootscreenService.ts | 2.59375 | 3 | import {UtilityService} from "./UtilityService";
export class BootscreenService{
public startBootSequence(): void {
}
public finishBootSequence(): void {
const bootscreen: HTMLElement | null = document.getElementById("bootscreen");
if(bootscreen) {
setTimeout(() => {
... |
0ead6ea2f439490fa2472f5998483ad073325273 | TypeScript | EdwardHinkle/whereisfelix.today | /index.ts | 2.59375 | 3 | import * as express from "express";
var needle = require("needle");
var moment = require("moment");
var ical = require("ical");
var app = express();
app.use(function(req, res, next) {
// Website you wish to allow to connect
res.setHeader("Access-Control-Allow-Origin", "https://whereisfelix.today");
// Request me... |
2c46deeaa652aee5a25399e3532fb7fa91dbf465 | TypeScript | elevu/clinical-genomics-ui | /src/api/GitHubApi.ts | 2.671875 | 3 | import { OpenNotification } from '../components/Toaster'
const gitHubURL = 'https://api.github.com/'
export type ApiUser = {
role: string
username: string
email: string
status: string
}
type GetUsersResponse = {
users: Array<ApiUser>
}
export const getRepos = async (): Promise<GetUsersResponse> => {
let... |
a705405990dbf5f35ecb7a95b36dd7ba072edd45 | TypeScript | pegaltier/rxjs-primitives | /libs/rxjs/string/src/lib/char-code-at.ts | 3.84375 | 4 | /**
* @packageDocumentation
* @module string
*/
import { Observable, OperatorFunction } from 'rxjs';
import { map } from 'rxjs/operators';
/**
* The `charCodeAt` operator can be used with an {@link https://rxjs-dev.firebaseapp.com/guide/observable|Observable} string
* value and returns a number of the ASCII code ... |
1133b9630935cf06f034e5aa85622f872bc22ccd | TypeScript | greeeg/paris-subway-map | /src/types.ts | 2.734375 | 3 | export interface StationLiaison {
id: string;
uuid: string;
}
export interface Station {
uuid: string;
name: string;
geolocation: number[];
accessibility: {
vision: boolean;
mobility: boolean;
};
// List of RATP stations ids
stations: string[];
}
export interface Line {
id: string;
name:... |
68eb03fb93d8dffffbca78f12710eebec5bea5c5 | TypeScript | Ravina1604/File-Upload | /file-upload/src/api/fileApi.ts | 2.796875 | 3 | import axios from "axios";
const FormData = require("form-data");
interface File {
fieldname: string;
originalname: string;
encoding: string;
mimetype: string;
destination: string;
filename: string;
path: string;
size: number;
}
class FileAPI {
private files: File[] = [];
private url = "http://loc... |
79eb9088bb0f5b6012b6216cb1c1d19adea8f480 | TypeScript | Sixing/TerisGame | /src/core/TerisRule.ts | 3.4375 | 3 | /**
* 该类中提供一系列的函数,根基游戏规则判断各种情况
*/
import {Shape, Point, MoveDirection }from './Types'
import {SquareGroup} from './SquareGroup'
import GameConfig from './GameConfig'
function isPoint(obj: any): obj is Point{
if(typeof obj.x === 'undefined') {
return false
}
return true
}
export class TerisRule {
/**
... |
55ed55dabc1db1232d15dee233cc5fb6b751e53a | TypeScript | oliver3/goedemorgenbot | /src/engine.ts | 2.84375 | 3 | import * as Promise from 'bluebird';
import { log } from './common/log';
import { Message } from 'telegram-api-types';
export type CommandFunction = (msg: Message, ...args: string[]) => Promise<string[]>;
export type RespondFunction = (msg: Message, responses: string[]) => Promise<any>;
export const handleMessage = ... |
1b4ee0f4ee091d90c7827de222767de80f1de908 | TypeScript | wuzzabi/price-monitoring-ipz | /backend/src/services/product.service.ts | 2.734375 | 3 | import HttpException from "@exceptions/HttpException"
import { Products } from "@models/products.model"
import IProduct from '@interfaces/products.interface'
import { isNumber } from "util"
export default class ProductService {
constructor() {}
public async getProductsByCategory(categoryId: number): Promise<I... |
15f4f73b962f6e90a018ec4ba160375899fd3607 | TypeScript | Emobe/croupier | /src/Deck.ts | 3.390625 | 3 | import { default as Card, Rank, Suit, ranks, suits } from './Card';
interface DeckOptions {
seed?: number;
shuffle?: boolean;
jokers?: boolean;
}
export default class Deck {
private cards: Card[] = [];
/**
* Create a deck of cards
*/
constructor(options: DeckOptions = {}) {
// TODO add jokers
... |
78cea1517b62673e3d8149f1f199b5dcbd9b8236 | TypeScript | ray-kay/trip | /src/app/shared/helpers.ts | 2.96875 | 3 | import {Destination} from './model/destination';
export class Helpers {
static moveArrayElement(arr: any[], old_index: number, new_index: number): any[] {
while (old_index < 0) {
old_index += arr.length;
}
while (new_index < 0) {
new_index += arr.length;
}
if (new_index >= arr.length)... |
d5dcf23c1cfaa4428a1a5d01d7420a7ad5f5ba2f | TypeScript | cristianmercado19/Redux-vanilla-js | /cart/actions/cart-reducer-initializer.ts | 2.53125 | 3 | import { UpdateShippingAddressReducer } from './update-shipping-address/update-shipping-address-action';
import { CartReducer } from './cart-reducer';
import { RequestOrderItemsProgressReducer } from './request-order-items-progress/request-order-items-progress-action';
import { UpdateOrderItemsReducer } from './update-... |
edff58c15f8ee2eb1b53dc88d25c6affa17e41bb | TypeScript | vitaliipetrunenko/substrataTest | /code/src/store/bitcoin/main.reducer.ts | 2.921875 | 3 | import {
BitcoinActions,
DECREASE_BITCOIN_PRICE,
INCREASE_BITCOIN_PRICE,
PURCHASE_BITCOIN,
SELL_BITCOIN,
TAKE_DEPOSIT,
TAKE_WITHDRAWAL,
} from "./main.types";
import { History, historyService } from "./history.service";
export type BitcoinState = {
balance: number;
bitcoins: number;
bitcoinPrice: n... |
3b90b3fcbede5e554b19742f97294eb14eab03e9 | TypeScript | AshrafSharf/building-observable | /simple-observable/SimpleObservable.ts | 2.75 | 3 | function SimpleObservable(observerSetupFunction) {
this.observerSetupFunction = observerSetupFunction;
}
SimpleObservable.prototype.subscribe = function (subscriber) {
let observer = {
next: function (data) {
subscriber(data);
}
}
this.observerSetupFunction(observer);
}
export default SimpleObs... |
1115dd582648dba601ea95350d6228a944d4eddf | TypeScript | GitbookIO/proxies-on-cloudflare | /src/firebase/types.ts | 2.625 | 3 | export interface FirebaseConfig {
rewrites: FirebaseRewrites;
}
export interface FirebaseRewrites extends Array<FirebaseRewrite> {}
export interface FirebaseFunctionRewrite {
source: string;
function: string;
}
export interface FirebaseDestinationRewrite {
source: string;
destination: string;
}
export typ... |
fbd11fbf3fcb0f8034abaef9577ae893004b89aa | TypeScript | K4M1s/typing-grinder | /resources/js/TypingField/Letter.ts | 3.8125 | 4 |
/**
* Letter type
*/
export enum LETTER_TYPE {
PLACEHOLDER,
TYPED_LETTER
}
/**
* Letter class
*/
export default class Letter {
private letter: string;
private typedLetter: string | null = null;
private element: HTMLElement;
/**
* Creates an instance of letter
* @param letter L... |
272066a067fa9503dfb29ff545bee06c9586a3e4 | TypeScript | brandynm34/SPEDcal | /src/mocks/providers/items.ts | 2.703125 | 3 | import { Injectable } from '@angular/core';
import { Item } from '../../models/item';
@Injectable()
export class Items {
items: Item[] = [];
defaultItem: any = {
"name": "Burt Bear",
"profilePic": "assets/img/speakers/bear.jpg",
"groupNumber": "Group 1",
};
constructor() {
let items = [
... |