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 |
|---|---|---|---|---|---|---|
d78248019b8837507a81516c850b9c8a04b46eff | TypeScript | aizigao/keepTraining | /basic_review/type-challenge/meduim/612-medium-kebabcase.ts | 2.953125 | 3 | /*
612 - KebabCase
-------
by Johnson Chu (@johnsoncodehk) #medium #template-literal
### Question
`FooBarBaz` -> `foo-bar-baz`
> View on GitHub: https://tsch.js.org/612
*/
/* _____________ Your Code Here _____________ */
// type KebabCase<S> = any;
type recurse<S extends string> = S extends `${i... |
7eafa7ee578c89a9335a5a359de6eb546f763747 | TypeScript | distunal/KungFuScreeps | /src/Military/Military.Intents.Helper.ts | 2.78125 | 3 | import _ from "lodash";
import { ACTION_MOVE, ERROR_ERROR, MemoryApi_Military, UserException } from "Utils/Imports/internals";
export class MilitaryIntents_Helper {
/**
* Get the map of the creeps based on their caravan position
* @param creeps the creeps in the squad
* @param instance the instance... |
aa4c3b49ddd963e5b72e5abd2fbe2f942c4a2783 | TypeScript | pisa-kun/practice_ts_oreilly | /chapter5/src/shoe.ts | 3.75 | 4 |
interface Shoe {
purpose :string
}
class BalletFlat implements Shoe{
purpose = 'Dancing'
}
class Boot implements Shoe{
purpose = 'woodcutting'
}
class Sneaker implements Shoe{
purpose = 'walking'
}
let Shoe = {
create(type : 'balletFlat' | 'boot' | 'sneaker'): Shoe{
switch(type){
... |
7552c58d67c677f964561057d0a3fd760bde409b | TypeScript | etcdigital/atomic-css | /packages/css/src/hash/index.ts | 3.140625 | 3 | // tslint:disable: no-bitwise
/*
* @ see more in
* https://github.com/garycourt/murmurhash-js
*/
const hasher = (str: string): string => {
const z = 0x5bd1e995;
const y = 0xe995;
const x = 16;
const w = 0xffff;
const v = 24;
const c = (s: string, i: number) => s.charCodeAt(i) & 0xff;
const g = (k: any) => (... |
2a3bd9e06a4c10e83e9a288073fd755664ba1998 | TypeScript | vofus/webgl_lessons | /src/tools/m3.ts | 2.671875 | 3 | // https://webglfundamentals.org/webgl/lessons/ru/webgl-2d-matrices.html
export const m3 = {
translation: function (tx: number, ty: number): number[] {
return [
1, 0, 0,
0, 1, 0,
tx, ty, 1,
];
},
rotation: function (angleInRadians: number): number[] {
... |
86b33c1dfc736010f51b37130088f35ad3bbbf5a | TypeScript | Garavirod/share-letters-cli | /src/app/models/escritor-model.ts | 2.859375 | 3 | import { Historia } from "./historia-model";
export class Escritor {
public id: string;
public username: string;
public email: string;
public about: string;
public imageURL: string;
public numHist: number;
public historias: Array<any>;
constructor(){
this.id =... |
8fdcb8d41e8428035b021707e3ee0e6535cb90fc | TypeScript | KoheiNishino/js_practice | /typescript-todo-app/src/index.ts | 3.34375 | 3 | // 追加ボタンの処理
const onClickAdd = () => {
const addText: HTMLInputElement = document.getElementById("add-text") as HTMLInputElement
if (!addText.value || !addText.value.match(/\S/g)) {
alert("Todoを入力してください。")
return
}
createUnfinishedTodos(addText.value)
addText.value = ""
}
const createUnfinishedTodos... |
4e0cc7bc4a85eadf20105ea8bac99a0cf62a8531 | TypeScript | bolollo/protomaps.js | /test/json_style.test.ts | 2.65625 | 3 | import { filterFn, numberOrFn, numberFn, getFont } from '../src/compat/json_style'
import assert from 'assert'
import baretest from 'baretest'
test = baretest("Json Style")
test("==",async () => {
let f = filterFn(['==','building','yes'])
assert(f(0,{props:{"building":"yes"}}))
})
test("!=",async () => {
... |
6f27c2ea34ea69a7b78d06bd6c09c5e2f39b3552 | TypeScript | Kobzol/davis | /src/app/emulation/instruction/bitwise.ts | 2.515625 | 3 | import {BinaryOperation} from "./instruction";
import {CPU} from "../cpu";
export class And extends BinaryOperation
{
execute(cpu: CPU): number
{
this.target.setValue(cpu.alu.and(this.target.getValue(), this.source.getValue()));
return cpu.getNextInstruction();
}
}
export class Or extends B... |
8d21497a5c3cb65d45bc6586669714c586043d02 | TypeScript | dhindustries/saggitarius-path | /src/driver/posix.ts | 3.03125 | 3 |
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, mod... |
0bc5f2be7f5ec68f04302d61f3142057aba61632 | TypeScript | SmileSmith/puppeteer-e2e | /tests/utils/index.ts | 2.890625 | 3 | import { DirectNavigationOptions, Target } from 'puppeteer';
/**
* 为Url添加参数
*
* @export
* @param {string} url
* @param {({ [key in string]: string | number | boolean })} params
* @returns
*/
export function addUrlParam(url: string, params: { [key in string]: string | number | boolean }) {
const urlArr = url.s... |
85100f6ddf4167745d8e3348818a2186c6619ec4 | TypeScript | Assasindie/fortniteBot | /src/core/EventCore.ts | 2.71875 | 3 | import * as Discord from "discord.js";
import * as winston from "winston";
import Logger from "log/Logger";
import NikkuCore from "core/NikkuCore";
import OnMessageState from "state/OnMessageState";
export default class EventCore {
private readonly logger: winston.Logger = new Logger(this.constructor.name).getLogg... |
fe9f61e75006f938288a553cfe788ad068420904 | TypeScript | wlee88/iam.alexplescan.com | /src/CanvasCreator.ts | 2.515625 | 3 | export class CanvasCreator {
createAndAddToDocument (): HTMLCanvasElement {
const canvas = document.createElement('canvas')
canvas.style.position = 'absolute'
canvas.width = window.innerWidth
canvas.height = window.innerHeight
document.body.prepend(canvas)
return canvas
}
}
|
1e08e63c68deb663ee6d4a1340762ba1c60d593c | TypeScript | justinefication/assalaam-pmis | /src/app/member.service.ts | 2.609375 | 3 | import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class MemberService {
constructor() { }
getMemberInfo(memberID: string) {
/*
| If the length of the entered member code is greater than
| or equal to 8, try to search for the member.
*/
if (memberID ==... |
2cb192f7cc9bc32f1359d0a4bd8cccdb5ab282c4 | TypeScript | user-hejun/up_2020 | /TS/demo1.ts | 2.5625 | 3 | function terry() {
let web : string = 'hello world'
console.log(web);
}
terry() |
6b5b2aa77a422caa8d691cf033c6764afb568e68 | TypeScript | gj262/thewatertemp-reactified | /src/reducers/temperatureData.ts | 3 | 3 | import { Action, ActionTypes, TemperatureDataIds, Temperature, TemperatureRange, ComparisonList } from "../types";
interface SingleTemperatureState {
isLoading: boolean;
data?: Temperature;
failure?: Error;
}
interface TemperatureRangeState {
isLoading: boolean;
data?: TemperatureRange;
failure?: Error;
}... |
0cabeab2c8287de2fee044eab75ba26f0797a84c | TypeScript | restuwahyu13/express-payment-gateway | /src/utils/util.uniqueNumber.ts | 2.5625 | 3 | export const uniqueOrderNumber = (): string => {
const randomOrderNumber: string = Math.random().toString().replace('0.', '')
const getRandomOrderNumber: any = parseInt(4 + randomOrderNumber)
const getDigitOrderNumber: RegExpExecArray = /\d{10}/.exec(getRandomOrderNumber)
const mergeDigitOrderNumber: string = getDi... |
3a8514fd1cd8bf29a3f1a74f37a3309867db87f6 | TypeScript | MySocialApp/mysocialapp-ts-client | /src/models/model.ts | 2.828125 | 3 | import * as _ from 'lodash';
import {Configuration} from "../configuration";
export interface ModelInterface {
load(o: object, conf: Configuration)
}
export interface Serializable {
toJson(): string
getJsonParameters(): {}
}
export class Model implements ModelInterface, Serializable {
protected conf... |
507e42f2c3cd0083256c274107e91720f3e7f990 | TypeScript | owncast/owncast | /web/components/stores/application-state.ts | 2.890625 | 3 | /*
This is a finite state machine model that is used by xstate. https://xstate.js.org/
You send events to it and it changes state based on the pre-determined
modeling.
This allows for a clean and reliable way to model the current state of the
web application, and a single place to determine the flow of states.
You can... |
06c87bb0bf452d911a373afedf04622a5d9af88b | TypeScript | amoungui/ecom-with-typeorm | /src/src/controllers/CheckoutController.ts | 2.515625 | 3 | import { Request, Response } from "express";
import Cart from "../entity/Cart";
import { Product } from "../entity/Product";
import session = require("express-session");
import * as Stripe from 'stripe';
class CheckoutController{
static getCheckout = async (req: Request, res: Response) => {
var message = ... |
4085e19ff9fc287b7de4253ceb94b3cf444d4a52 | TypeScript | paolotiu/crud-app-examples | /todo-graphql-typescript/backend/src/util/createVariablesString.ts | 3.296875 | 3 | export const createVariablesString = (arr: any[]) => {
// Create the variables string
// [1,5,3,9] => "$1,$2,$3,$4"
let vars = "";
for (let i in arr) {
const index = parseInt(i) + 1;
if (index >= arr.length) {
vars = vars + "$" + index;
} else {
vars = `${vars}$${index},`;
}
}
r... |
1c01f99b5218acbd6f5cbb4fe16702f4c6b6a19c | TypeScript | JulienBergeon/gsb-nest | /src/doctor/doctor.controller.ts | 2.96875 | 3 | import { Controller, Get, Request, UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { ApiResponse, ApiUseTags } from '@nestjs/swagger';
import { UserDtoConverter } from '../users/converter/userDto.converter';
import { UserDto } from '../users/model/user.dto';
import { User } from ... |
b78049fca7f425c1a4e3f1f3b4f21a5910f76d86 | TypeScript | hrokhbakhsh/formgenerator | /src/app/form/show-form/show-form.component.ts | 2.546875 | 3 | import { Component, OnInit } from '@angular/core';
import {FormArray, FormBuilder, FormGroup} from "@angular/forms";
import {animate, state, style, transition, trigger} from "@angular/animations";
import {InputComponent} from "../input/input.component";
import {MatDialog} from "@angular/material/dialog";
export interf... |
220980b420e8d007fbbb6ade2944295e9129b200 | TypeScript | linkinvo/nextjs-blog-main | /server/models/reviewsModel.ts | 2.65625 | 3 | import { Model, DataTypes, BuildOptions } from "sequelize";
import { IContextContainer } from "./../container";
interface IReviews extends Model {
id: number;
feedback: string;
createdAt: BigInt;
propertiId: number;
userId: number;
}
export type ReviewsType = typeof Model & {
new(values?: object, options?... |
405a9ada8d36a6c02ae23945a928c2a2e2fde185 | TypeScript | Rakeshjayaraj/sample-code-house | /sample-code-house/src/app/house-list/house-list.component.ts | 2.96875 | 3 | import { Component, OnInit } from '@angular/core';
import { ApiService } from '../services/api.service';
import { House } from '../models/house';
@Component({
selector: 'app-house-list',
templateUrl: './house-list.component.html',
styleUrls: ['./house-list.component.css']
})
export class HouseListComponent impl... |
2d078871fcf33bd42a71020f24131d88e585b0b1 | TypeScript | bonejon/ngrx-sample | /src/app/store/cart/cart.spec.ts | 2.546875 | 3 | import { CartState, InitialCartState } from './cart.state';
import { CartItem } from 'src/app/common/models/cart-item';
import { AddItemToCartActionSuccess } from './cart.actions';
import { cartReducer } from './cart.reducer';
import * as cartActions from './cart.actions';
import { cold } from 'jasmine-marbles';
import... |
78e691331892d72ecc4b7c9749105c096920ca85 | TypeScript | SemajDraw/GradAcademy | /TypeScriptAndAngularProjects/TypeScriptProjects/TypeScriptSolutions/CleanCode/src/app/unique-words/unique-words.component.ts | 3.0625 | 3 | import {Component} from '@angular/core';
import {orderBy} from 'lodash';
import {HttpClient} from '@angular/common/http';
@Component({
selector: 'app-unique-words',
templateUrl: './unique-words.component.html',
styleUrls: ['./unique-words.component.css']
})
export class UniqueWordsComponent {
input = '';
out... |
b68a655b01574d326933dba08543f958d9c51bfc | TypeScript | johannes85/prowljs | /src/test/ts/prowl/ProwlTest.ts | 2.640625 | 3 | import * as Mocha from 'mocha';
import * as assert from 'assert';
import * as nock from 'nock';
import Prowl from '../../../main/ts/prowl/Prowl';
describe('Prowl', () => {
let p: Prowl;
let successAnswer: string = '<?xml version="1.0" encoding="UTF-8"?><prowl><success code="200" remaining="123" resetdate="456789... |
5a61e8d947060c95bb6210e144b2071eef4ee609 | TypeScript | wthapps/portal-frontend | /src/shared/shared/pipe/phone-to-flag.pipe.ts | 2.671875 | 3 | import { Pipe, PipeTransform } from '@angular/core';
declare var _: any;
@Pipe({
name: 'phoneCodeCountries'
})
export class PhoneCodeCountriesPipe implements PipeTransform {
transform(key: any, data: any): any {
if (key) {
const phoneName = key.split(' (+');
const phoneCode = _.find(data, ['name',... |
e52db0baa732f60494ba224918cefb770ca92d0c | TypeScript | mihajlo202/RWAProject_Angular_NgRx | /src/app/models/JobEmployed.ts | 2.703125 | 3 | export interface IJobEmployed {
id:number;
jobId:number;
workerId:number;
}
export class JobEmployed implements IJobEmployed{
id:number;
jobId:number;
workerId:number;
constructor(jobId, workerId) {
this.jobId = jobId;
this.workerId = workerId;
}
} |
00ea183af48ec8fc7662ea7b60db94fa8f18fece | TypeScript | Eoyo/read-key | /src/libs/state-machine.ts | 3.359375 | 3 | export function match(matcher: RegExp | string[] | string, key: string) {
if (Array.isArray(matcher)) {
return matcher.includes(key);
} else if (typeof matcher === "string") {
return matcher == key;
} else if (matcher instanceof RegExp) {
return matcher.test(key);
} else {
return matcher === key... |
23e18316d7ed7afacb8b744f8e0e20f22e096330 | TypeScript | thekevinscott/UpscalerJS | /test/integration/utils/catchFailures.ts | 2.53125 | 3 | export function catchFailures<T extends unknown[]>() {
return (
_1: unknown,
_2: string | symbol,
descriptor: PropertyDescriptor
) => {
const origFn = descriptor.value;
descriptor.value = async function (...args: T) {
try {
return await origFn.apply(this, args);
} catch (err)... |
4a9c0a9ec63caea6e812098d68855bfd237e777f | TypeScript | jayeshyadav89/Angular2 | /demo_proj/Routing/app.department.details.component.ts | 2.515625 | 3 | import {Component, OnInit} from "@angular/core";
import {ActivatedRoute, Params, Router} from "@angular/router";
@Component({
template : `You have selected department : {{departmentId}}<br/>
<a (click)="goPrevious()">Previous</a>
<a (click)="goNext()">Next</a>
<p>
<b... |
fea91aebcf95c6236fdb100a9bb549c0993c262b | TypeScript | tinymce/tinymce | /modules/bridge/src/main/ts/ephox/bridge/components/menu/SeparatorMenuItem.ts | 2.515625 | 3 | import { StructureSchema } from '@ephox/boulder';
import { Optional, Result } from '@ephox/katamari';
import * as ComponentSchema from '../../core/ComponentSchema';
export interface SeparatorMenuItemSpec {
type?: 'separator';
text?: string;
}
// tslint:disable-next-line:no-empty-interface
export interface Separa... |
f8379348df16c4195603d0db9adc7718807fc815 | TypeScript | ky0yk/ohakuma-api | /test/lambda/dynamodb-bear-management-table.test.ts | 2.640625 | 3 | import * as infra from '../../src/lambda/infrastructures/dynamodb/dynamodb-bear-management-table';
import { mockClient } from 'aws-sdk-client-mock';
import * as ddbLib from '@aws-sdk/lib-dynamodb';
import { Bear } from '../../src/lambda/domains/bear-management/bear-management';
import { v4 as uuidv4 } from 'uuid';
con... |
faa44821e7ae069e518462f2a3bf380c4fc77707 | TypeScript | Brenont/site | /src/_mocks/SelectiveProcess.mock.ts | 2.578125 | 3 | export interface ISelectiveProcessItem {
title: string;
description: string;
}
export const selectiveProcessMock: ISelectiveProcessItem[] = [
{
title: "TESTE DE CLASSIFICAÇÃO",
description:
"Uma prova de raciocínio lógico. Simples e objetiva. Funciona como uma classificação de acordo com o número d... |
60db4b7069cdcc7f14b18d53b72b9fd9b18e7619 | TypeScript | Svreber/ludos | /backend/src/modules/language/domain/language.output.ts | 2.609375 | 3 | import { Field, ID, ObjectType } from 'type-graphql';
@ObjectType()
export class LanguageOutput {
private _type = 'output';
@Field(type => ID)
id?: number;
@Field()
name?: string;
@Field()
nameEnglish?: string;
@Field()
nameAlpha3?: string;
}
|
fb165c3445255ad568ccf7f7cb959324f1ca7f83 | TypeScript | Lagunskij/Lagunskij | /src/store/todolists-reducer.test.ts | 2.953125 | 3 | import {
ActionType,
AddTodoListAC,
ChangeTodoListFilterAC, ChangeTodoListTitleAC,
RemoveTodoListAC,
todolistsReducer
} from './todolists-reducer';
import {v1} from 'uuid';
import {FilterValuesType, TodoListType} from '../App';
let todolistID1:string;
let todolistID2: string;
let startState: Array... |
6ff0705d1209a5bfa73fe672404cdbd788dff384 | TypeScript | ilomon10/solar-power-monitor | /functions/src/addData.ts | 2.515625 | 3 | import { https, Response, config } from 'firebase-functions';
import db from './db';
export interface IData {
device: string;
powerIn: number;
powerOut: number;
voltageIn: number;
voltageOut: number;
currentIn: number;
currentOut: number;
temperature: number;
timestamp: number;
}
export const handle... |
d93a00ca9d8419eb6e5e7df53b59468b1daca359 | TypeScript | tom-sherman/smart-home | /services/device-registry-service/src/schema/registering.ts | 2.609375 | 3 | import {
arg,
inputObjectType,
list,
mutationField,
nonNull,
objectType,
} from 'nexus';
import { v4 as uuid } from 'uuid';
import { NexusGenInputs } from '../generated/nexus-typegen';
import { Capability, EnumCapability, NumericCapability } from '../sourceTypes';
import { Device, Access } from './schema';
... |
affc2ed40ccf47d80073bf7a87f1ca5680677fae | TypeScript | ffalt/jamserve | /src/modules/rest/builder/express-path-parameters.ts | 2.8125 | 3 | import {CustomPathParameterGroup, CustomPathParameters} from '../definitions/types';
import {MethodMetadata} from '../definitions/method-metadata';
import {InvalidParamError, MissingParamError} from './express-error';
import {getMetadataStorage} from '../metadata';
function validateCustomPathParameterValue(rElement: s... |
081f8dea76a4a9b2e13afa66f91a27fcedb7e55f | TypeScript | simonjamesrowe/react-ui | /src/state/socialMedia/Reducer.ts | 2.59375 | 3 | import { Reducer } from "redux";
import { ISocialMediaState} from "../Store";
import { SocialMediaActions, SocialMediaActionTypes} from "./Actions";
const initialSocialMediaState: ISocialMediaState = {
loading: false,
socialMedias: []
};
export const socialMediaReducer: Reducer<ISocialMediaState, SocialMedia... |
af9626175e35ab50f0f40dceab4008e03c15406d | TypeScript | woutervh-/taskdist | /src/shared/messages/master-to-worker.d.ts | 2.625 | 3 | export interface TaskMessage<Task> {
type: 'task';
key: string;
task: Task;
}
export type MasterMessage<Task> = TaskMessage<Task>;
|
4b96f545483cb9b03b4b8185c83aa8e96b5794db | TypeScript | uxland/uxl-test-release | /test/unit/invariant-fixture.ts | 3.328125 | 3 | import {invariant} from '../../src/invariant';
import {assert, expect} from 'chai';
import * as sinon from 'sinon';
suite('when invoking `invariant` method', () => {
suite('and a value is passed as first argument', () => {
test('should return undefined if first argument is truthy', () => {
asse... |
8b641ad706e6ebab1a181ce37d8e48ad4c41b28e | TypeScript | Skidush/webui-Talos | /e2e/utils/element.utils.ts | 2.9375 | 3 | import { browser, ElementFinder, ElementArrayFinder } from "protractor";
import { ElementCommand, ElementCommandCycle, SelectorParameter } from '../helpers/helper.exports';
export class ElementUtil {
/**
* Checks if the timeout for retrying has been exhausted.
* Throws an error and resets the global time... |
d3e39a1b878afe958af4b689a201ae9cc2bd04be | TypeScript | aqualaguna/validator-class | /src/chain/ruleFunction/comparisonRule/afterEqualRule.ts | 2.671875 | 3 | import strtotime from '../../helper/strtotime';
import dateRule from '../typeRule/dateRule';
export default function afterEqualRule (data: any, params: any) {
if (dateRule(data, params)) {
let d = new Date(data);
let ms = strtotime(params.value.join(','), (new Date()).getTime());
if (typeof ms == "boolean... |
694464a8fa8af28d458325199c29c0aa35643d29 | TypeScript | moredrowsy/react-native-sudoku | /src/storage/store/slices/status.slice.ts | 2.671875 | 3 | import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { RootState, AppThunk } from '..';
import * as LocalStorage from '../../local-storage';
import { AppStatus } from '../../../types';
const sliceName = 'status';
const initialState: AppStatus = {
isLoggedIn: false,
loading: true,
userId: null,
... |
90efca8e3a2cc83a1a3cf9473caa361b9cd18914 | TypeScript | lcostash/backend.terence.one | /src/strategy/local.strategy.ts | 2.5625 | 3 | import { BadRequestException, Injectable, UnauthorizedException } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport';
import { Strategy } from 'passport-local';
import { registerSchema, validate } from 'class-validator';
import { AuthService } from '../service';
import { LocalValidation } from '... |
5f2e355e543273be0add88c50040a175b34db0db | TypeScript | isaacsimmons/aoc2020 | /src/day7/main.ts | 3.078125 | 3 | import { truthy } from '../utils/array';
import { readInputLines } from '../utils/file';
const inputLines = readInputLines();
interface Rule {
color: string;
contents: Contents[];
}
interface Contents {
color: string;
quantity: number;
}
const contents = new Map<string, Map<string, number>>();
const... |
8b79c6f18633e968e0b6f4d2173329986319ffe1 | TypeScript | PrashanthEttaboina/java-programing | /TypeScript/union.ts | 3.53125 | 4 | function display(value: number | string)
{
if(typeof(value)=="number")
console.log("Value is number : "+value);
else
console.log("value is String : " +value);
}
display(11);
display("Hello World");
|
438a89333761c5d67a009b7332a0ab311f6b18c8 | TypeScript | nhn/tui.chart | /apps/chart/tests/store/store.spec.ts | 2.8125 | 3 | import Store from '@src/store/store';
import { BaseOptions } from '@t/options';
import { ChartOptions } from '@t/store/store';
describe('Store', () => {
let store: Store<BaseOptions>;
describe('Computed', () => {
beforeEach(() => {
store = new Store({} as any);
store.setRootState({
chart:... |
ecfa51f3e7bb4e33b543abbaeea2249f8c813c27 | TypeScript | TheBigMoon/SWGeek | /src/redux/reducers/planetsReducer.ts | 2.828125 | 3 | import { PlanetsStore } from '../../types/store/store';
import { PlanetsActionType } from '../../types/actions/planetsActionTypes';
import {
SET_PLANET, SET_PLANETS, SORT_PLANETS_BY_A_Z, SORT_PLANETS_BY_Z_A
} from '../../constants/actionTypeConstants';
import { sortHelper } from './reducerHelpers/sortHelper';
const ... |
a964c2ef0a7f731460d10860c3a8fd3d15784d50 | TypeScript | ZnoGouDj/codewars-challenges | /4kyu/4kyu-human-readable-duration-format.ts | 3.5625 | 4 | function formatDuration(seconds) {
const time = {
year: '',
day: '',
hour: '',
minute: '',
second: '',
};
const result: string[] = [];
while (seconds) {
if (seconds / 60 / 60 / 24 / 365 >= 1) {
time.year = String(Math.floor(seconds / 60 / 60 / 24 / 365));
seconds -= +time.y... |
c5f0f0c45fed80c016152310c289c45912d03c60 | TypeScript | hallieliu123/typescript-study | /basic/9generic.ts | 4.3125 | 4 | // generic泛型,泛指的类型
//1.函数中的泛型
//a/
function add<ABC>(param1: ABC, param2: ABC): ABC {
return param2;
}
add<number>(1 ,2);
//b/
function join1<T, P>(p1: T | P, p2: T | P){}
join1<number, number>(1, 1);
join1<string, string>('a', 'b');
join1<string, number>('a', 1);
//c/. T[]
function loop<T>(param: Array<T>) {}
loo... |
8f14e540cd0e7f6730de4019f40e11eb662d2cd2 | TypeScript | VIDIUN/ngx-client-11.0.0 | /package/lib/api/types/PartnerGetUsageAction.d.ts | 2.59375 | 3 | import { KalturaObjectMetadata } from '../kaltura-object-base';
import { KalturaPartnerUsage } from './KalturaPartnerUsage';
import { KalturaReportInterval } from './KalturaReportInterval';
import { KalturaRequest, KalturaRequestArgs } from '../kaltura-request';
export interface PartnerGetUsageActionArgs extends Kaltur... |
02d1a0b727def46ffa25eea31df494adb9c660b4 | TypeScript | kvijaygiri/ecommerce | /src/app/CustomValidation.ts | 2.65625 | 3 | import {AbstractControl,ValidatorFn} from '@angular/forms';
export function NameValidation():ValidatorFn{
return (control:AbstractControl):{[key:string]:boolean}|null =>{
if(control.value.trim()=="flipkart"){
return{'NameNotAllowed':true};
}
return null;
};
} |
a2fa2ea43e009e72b6a1d2d2d7e1c8534b33c8b3 | TypeScript | AdvaithD/hodlol | /test/scenario-test.ts | 3.109375 | 3 | import { Scenario } from "../src/models/types"
import "mocha";
const sinon = require("sinon");
const assert = require("assert");
describe("logger functionality", () => {
it("should given numbers for start/end a scenario should assume they are timestamps", () => {
const json = {
id: "foo",
... |
f1bab51838630aecc21cbf77d20f08130e239fe6 | TypeScript | devbratraghuvanshi/RegencyTours | /src/cms/model/packageImage.ts | 2.53125 | 3 | import { Document, Schema, Model, model } from 'mongoose';
// PackageImage Interface
export interface IPackageImageModel extends Document {
//_id
packageId: Schema.Types.ObjectId;
imageUrl: string;
imageTag: string;
attribute: string;
status: Boolean;
createdBy: String;
createdAt: Date... |
516e6192b99aae68c31788ae3caa7abcfbc53964 | TypeScript | kylekanouse/EventsGraph | /src/server/lib/Entity.ts | 3.015625 | 3 | import { v4 as uuidv4 } from "uuid";
import IEventData from "../domain/IEventData";
import IEventsData from "../domain/IEventsData";
import IGraphData from "../domain/IGraphData";
import IGraphEntity from "../domain/IGraphEntity";
import IGraphLink from "../domain/IGraphLink"
import IGraphNode from "../domain/IGraphNod... |
e208888c524739770cff9c2b30c850e811a70b51 | TypeScript | IdealCattree/MeowVideoServer | /src/entities/Movie.ts | 2.90625 | 3 | import { ArrayMinSize, IsNotEmpty, Max, Min, validate } from "class-validator";
import { Type, plainToClass } from "class-transformer";
import { BaseEntity } from "./BaseEntity";
export class Movie extends BaseEntity {
@IsNotEmpty({ message: "电影名称不能为空" })
@Type(() => String)
public name: string;
@IsNotEmpty({ ... |
41805255f01d4db43c711798163ad776c3e43cb5 | TypeScript | Eva-AlHindy/Ang3-EvaAlHindy | /src/app/route-guard.service.ts | 2.734375 | 3 | /* Import (Router, CanActivate), and inject the router into constructor of the class.
This class has a proparty (authorized) which has a boolean typescript and it refers if there is user in local storge or not.
And one method (canActivate()).
This method makes a checkup if the username is saved in the local storage t... |
2ac03a8ba4b736dae44d91ebcc162b5208a90cad | TypeScript | danikaze/ascii-ui | /src/widgets/Text.ts | 2.9375 | 3 | import { CharStyle, Terminal, TileSize } from '../Terminal';
import { Widget, WidgetOptions } from '../Widget';
import { WidgetContainer } from '../WidgetContainer';
import { clamp } from '../util/clamp';
import { coalesce } from '../util/coalesce';
import { deepAssign } from '../util/deepAssign';
import { noWrap, spl... |
5b66224e968229a9ce06c66999b939b8373288b1 | TypeScript | LDWDev/MEAN-stack-playground | /src/app/services/stream-handler.service.ts | 2.5625 | 3 | import { Subject, Subscription, Observable } from "rxjs";
import { takeUntil } from "rxjs/operators";
import { OnDestroy, Injectable } from "@angular/core";
@Injectable()
export class StreamHandler implements OnDestroy {
public subscriptions: Subscription[];
private _destroy$: Subject<boolean>;
constructor() {
... |
e2b3d17937576a4c17766b0e7968bd9b0398decc | TypeScript | CatInEars/Task-Scrile | /src/modules/getFilteredUsers.ts | 2.875 | 3 | import { IUser } from "../types"
export function getFilteredUsers(allUsers: IUser[], searchText: string) {
return allUsers.filter((user: IUser) => {
return (
user.name.toLowerCase().includes(searchText.toLowerCase()) ||
user.username.toLowerCase().includes(searchText.toLowerCase())
)
})
} |
42eac8002d2986985d816268b1f9c6c094637da5 | TypeScript | cridaflo/platzi-store | /src/app/shared/pipes/agrupar/agrupar-productos.pipe.ts | 2.53125 | 3 | import { Pipe, PipeTransform } from '@angular/core';
import { Product } from '@core/models/product.model';
import { Observable, from } from 'rxjs';
@Pipe({
name: 'agruparProductos'
})
export class AgruparProductosPipe implements PipeTransform {
productsCount= [];
// transform(products: Product[]): any {
// ... |
c994365069990fd374b2c1c5057d75fb4f227860 | TypeScript | akheron/optics-ts | /src/standalone/operations.spec.ts | 3.046875 | 3 | import * as O from '.'
describe('get', () => {
const optic = O.prop('foo')
const source = { foo: 'bar' }
type Focus = string
it('total', () => {
const result: Focus = O.get(optic, source)
expect(result).toEqual('bar')
})
it('partial', () => {
const result: Focus = O.get(optic)(source)
expe... |
3fb30bdca1fd319996f202e64834c6759b164417 | TypeScript | Seafnox/ngx-sudocu | /src/components/cell-actions/cell-actions.component.ts | 2.640625 | 3 | import { Component, EventEmitter, HostListener, Input, Output } from '@angular/core';
import { Board } from '../../interfaces/board';
import { CellPosition } from '../../interfaces/cell.position';
import { Cell } from '../../interfaces/cell';
import { boardSize } from '../../consts/config';
@Component({
selector: 'a... |
3da687ffcf1037caaf3c9609f83302e8dd45caf1 | TypeScript | snakemode/massively-tetris | /src/tetris/World.ts | 2.921875 | 3 | import { Move, Mino, Cell, RotationOperation, IRotationSystem } from './Types';
import { SuperRotationSystem } from './SuperRotationSystem';
import { Tetromino } from "./Tetromino";
type Row = Cell[];
type MoveResult = { canMove: boolean, lock: boolean };
export class World {
public playerId: string;
public widt... |
fb23736682fbe1db3fc6cae11fcd8d7fc741fe30 | TypeScript | psousa50/hearts-game-core | /src/Tricks/domain.ts | 2.890625 | 3 | import { score as cardScore } from "../Cards/domain"
import { Card } from "../Cards/model"
import { Trick } from "./model"
export const createTrick = (cards: Card[] = [], firstPlayerIndex: number = 0): Trick => ({
cards,
firstPlayerIndex,
})
export const isEmpty = (trick: Trick) => trick.cards.length === 0
expor... |
0b2655656dedd664b5a632372f31ad40e8e57285 | TypeScript | NatanelMizrahi/kindred-marvel | /src/app/d3/models/link.ts | 2.65625 | 3 | import APP_CONFIG from '../../app.config';
import { Node } from './index';
export type LinkType = 'EVENT' | 'ALLIANCE';
export class Link implements d3.SimulationLinkDatum<Node> {
static STRENGTH_FACTOR = ((APP_CONFIG.LINK_WIDTH_FACTOR) / (APP_CONFIG.MAX_VISIBLE_CHARS)); // * Math.log10(APP_CONFIG.EVENT_LIMIT)
in... |
080bf5623cdc822ee3cae51714a0141a03b3eaf4 | TypeScript | ClaudiaFeliciano/Arrow-6 | /Scripts/objects/shoot.ts | 3.03125 | 3 | module objects {
export class Shoot extends objects.AbstractGameObject {
private _speed: number;
private _direction: math.Vec2;
private _isInPlay: boolean;
private _velocity: math.Vec2;
get Direction(): math.Vec2 {
return this._direction;
}
set Direction(newDirection: math.Vec2) ... |
c16717d023e3c91c96a8b15e4da283bf60a5d91c | TypeScript | pwcong/okeedesign-mobile-vue | /tests/unit/toast.spec.ts | 2.53125 | 3 | import { later } from '../index';
import { Toast as NativeToast } from '@src';
const Toast = NativeToast as any;
describe('Toast', () => {
test('create a forbidClick toast', async () => {
const toast = Toast({
forbidClick: true,
type: 'success',
});
await later();
expect(toast.$el.outerH... |
88d15d17b2875175ca86a70106deaaa1d23494b9 | TypeScript | BeMoreHuman/Mahjong-like-game | /src/app/app.component.ts | 2.703125 | 3 | import {
Component,
OnInit
} from '@angular/core';
import { GameServiceService } from './services/game-service.service';
export interface CardInterface {
value: number;
isEnabled: boolean;
isDone: boolean;
}
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.com... |
7dbb84cf17f3ac89b19c0d2621efffad6faae50b | TypeScript | cedelar/beartender_client | /src/app/_model/cocktail.model.ts | 3.1875 | 3 | interface CocktailJson {
name: string,
description: string,
imageLink: string
}
export class Cocktail{
constructor(
private _name: string,
private _description: string,
private _imageLink: string
){}
get name(): string {
return this._name;
}
get descrip... |
f3282bd3b3cb61c68dc624f6285c6b0fd1620f19 | TypeScript | theguvnors/CodingProblems | /ResponseChecking/Response2.ts | 2.84375 | 3 | console.clear();
type ModernResponse = { metadata: MetaData; body: unknown };
type MetaData = { apiVersion: string; callStatus: number };
type ValidationRule = { propName: string; propType: string };
class ApiModelValidator {
public validate(o: ModernResponse | any): boolean {
return this.isModernResponseO... |
822861d63b4350f0724ef14f04ccf34578821803 | TypeScript | noasand/grafana | /public/app/core/specs/emitter.test.ts | 3.046875 | 3 | import { Emitter } from '../utils/emitter';
describe('Emitter', () => {
describe('given 2 subscribers', () => {
it('should notfiy subscribers', () => {
const events = new Emitter();
let sub1Called = false;
let sub2Called = false;
events.on('test', () => {
sub1Called = true;
... |
da2607fe8b3a565ae9e5fbe1b2308b6aa0bb1c1e | TypeScript | triptu/withRetry | /src/withRetry.ts | 3.09375 | 3 | import { ResourceExhaustedError } from "./ResourceExhaustedError";
import { Settings } from "./Settings";
type WithRetry = <T, Y extends unknown[]>(
callback: (...args: Y) => Promise<T>
) => (...args: Y) => Promise<T>;
const defaults = {
maxCalls: 2,
errors: [],
delay: 0,
};
const sleep = async (intervalMs: ... |
2f1b9ebeabf1581525b2dbbb1f3f4ee6f86e2048 | TypeScript | swedesjs/rus-anonym-utils | /ts/src/lib/logical/core.ts | 4.09375 | 4 | /**
* @category Logical
* @description Класс для работы с логическими функциями
* @hideconstructor
*/
export class LogicalUtils {
/**
* Логическое И
* Конъюнкция
* Логическое умножение, выражение «AND».
* Конъюнкция возвращает true только тогда, когда оба аргумента равны true, иначе false.
... |
968e5420dc9644d455591481bdcfa282dfec405b | TypeScript | koladev32/node-express-jwt-tutorial | /src/middleware/middleware.ts | 2.5625 | 3 | import e, { Response, Request, NextFunction } from "express";
import { IUser } from "../types/user";
const jwt = require("jsonwebtoken");
const authenticateJWT = async (
req: Request,
res: Response,
next: NextFunction
): Promise<e.Response<any, Record<string, any>>> => {
const authHeader = req.headers.authori... |
04b7f5e26c1b56084e6066985db36dbd5408a472 | TypeScript | HAFDIAHMED/IgniteTraning | /app/models/profil/profil.ts | 2.59375 | 3 | import { flow, Instance, SnapshotOut, types } from "mobx-state-tree"
import { Api } from "../../services/api"
/**
* Model description here for TypeScript hints.
*/
export const ProfilModel = types
.model("Profil")
.props({
name : types.optional(types.string,""),
job : types.optional(types.string, "j... |
280b1d713a3eb7457481b492dd72a5980249f1ae | TypeScript | craig0chq0/tsPlayGround | /while.ts | 4.21875 | 4 | // 安装 nodejs
// 安装 nodejs 的 一个模块 typescript
// 循环资料
// http://www.runoob.com/js/js-loop-for.html
// http://www.runoob.com/js/js-loop-while.html
// http://www.runoob.com/js/js-break.html
// 实现一个函数,传入任意长度的数字数组,返回数组中所有元素相加的和
function getSum(arr: number[]) {
let sum: number = 0;
for (let i = 0; i < arr.length; ++... |
378c37557fd6c6009821901b8232f17831daa83e | TypeScript | letmaik/chip8 | /src/test/chip8.test.ts | 2.71875 | 3 | import { assert } from 'chai'
import { wasm, unboundWasm } from './wasm'
function loadProgram(program: Array<number>) {
wasm.init()
wasm.loadProgram(new Uint8Array(program))
return state()
}
function run(program: Array<number>) {
loadProgram(program)
return step()
}
function step(n = 1) {
for (let i = 0;... |
a790cc56aef960837727783712e2757458ce41dd | TypeScript | alphagov/passport-verify | /lib/passport-verify-strategy.ts | 2.53125 | 3 | /**
* A passport.js strategy for GOV.UK Verify
*/
/** */
import { Strategy } from 'passport-strategy'
import * as express from 'express'
import { createSamlForm } from './saml-form'
import VerifyServiceProviderClient from './verify-service-provider-client'
import { AuthnRequestResponse } from './verify-service-provid... |
7f2873b828db579fe072cd515b21399080a18dac | TypeScript | vinayakvivek/raytracer | /src/utils/perlin.ts | 3.03125 | 3 | import { clamp, randomBetween } from "./utils";
import { Point3, Vec3 } from "./vec3";
const count: number = 256;
const rands = new Float32Array(count);
const randVecs: Vec3[] = [];
const px = new Uint8Array(count);
const py = new Uint8Array(count);
const pz = new Uint8Array(count);
const generatePerlinPerm = (p: Uin... |
faa9bcf69edb029b995f2a4fce5d2ab6a7bc1b48 | TypeScript | xiong35/type-challenges-solutions | /src/0010-TupleToUnion-medium/index.ts | 3.40625 | 3 | namespace T0010 {
/* 答案 */
type TupleToUnion<T extends readonly any[]> = T[number];
/* 测试 */
type Arr = ["1", "2", "3"];
type A = TupleToUnion<Arr>; // expected to be '1' | '2' | '3'
}
|
d6ca66be5cc9f60c33f4cf19b0fcd06440487774 | TypeScript | moulins/kryo | /packages/kryo/src/test/types/codepoint-string.spec.ts | 2.890625 | 3 | import chai from "chai";
import unorm from "unorm";
import { CodepointStringType } from "../../lib/codepoint-string.js";
import { runTests, TypedValue } from "../helpers/test.js";
describe("CodepointStringType", function () {
describe("basic support", function () {
const type: CodepointStringType = new Codepoin... |
75ad76ab9a996c7e1b1e474f4a840e7b18532afd | TypeScript | darenhart/contact-list-brakets-angular4 | /src/app/brackets.component.ts | 2.5625 | 3 | import {Component} from '@angular/core';
@Component({
selector: 'brackets',
templateUrl: './view/brackets.component.html',
styleUrls: ['./scss/brackets.component.scss'],
providers: []
})
export class BracketsComponent {
brackets: string = "";
isValid: boolean;
constructor() {
}
validate(str): bo... |
3d862d2ee3b5805e8749418d437d715e9ef9862b | TypeScript | gkniazkov/nest-content-roles-permission | /src/cms/comments/use-comments.decorator.ts | 2.578125 | 3 | import { ReflectMetadata, SetMetadata } from '@nestjs/common';
//
// export const UseComments = (...args: string[]) => ReflectMetadata('use-comments', args);
//
// TODO user SetMetadata instead of target.useComment. Metadata can be reflected
export const UseComments = (target) => {
SetMetadata('use-comments', true);... |
3cf6d73b360f66a70578ef220a76df6c5edec300 | TypeScript | larilofman/react-rpg | /src/utils/collision.ts | 3.046875 | 3 | import { Rectangle } from '../types';
export function collision(rect1: Rectangle, rect2: Rectangle, gap = 0) {
return (rect1.pos.x < rect2.pos.x + rect2.size.w + gap &&
rect1.pos.x + rect1.size.w > rect2.pos.x - gap &&
rect1.pos.y < rect2.pos.y + rect2.size.h + gap &&
rect1.pos.y + rect1.s... |
1c03339ba6b4722c437e8c4861951256580dfa3f | TypeScript | kinali19/TheVeggieStore | /src/app/product/product.ts | 2.515625 | 3 | export interface Product {
name: string;
price: number;
description: string;
image: string;
quantity:number;
inCart:boolean
} |
b75cbaf6946dd81241a8b6d16681648a5522d452 | TypeScript | alfuveam/otwebclient | /modules/effect.ts | 2.53125 | 3 | import {Point, Timer} from "./structures";
import {Thing} from "./thing";
import {LightView} from "./lightview";
import {ThingType} from "./thingtype";
import {g_things} from "./thingtypemanager";
import {ThingCategory} from "./constants/const";
export class Effect extends Thing {
public static readonly EFFECT_TIC... |
fcf26cd4ec1e6eb9a30133653709c59a19e153a1 | TypeScript | tkryskiewicz/heroes-engine | /packages/heroes-core/src/objects/TradableObject.test.ts | 2.734375 | 3 | import { GameObjectData } from "../GameObject";
import { isObjectTradable, isTradableObjectData, TradableObjectData } from "./TradableObject";
describe("isTradableObjectData", () => {
it("should return true when tradable object data", () => {
const objectData: TradableObjectData = {
id: "id",
tradabl... |
0b86798c8cfec8468a8c36507bb37296dbecd6ac | TypeScript | MateuszSuder/REST-API-FRONTEND | /src/stores/RootStore.ts | 2.640625 | 3 | import {action, makeAutoObservable, observable} from 'mobx';
import { UserStore } from './UserStore';
import {CartStore} from "./CartStore";
export class RootStore {
readonly timeout = 3500;
user: UserStore;
cart: CartStore;
snackbarMessages: Array<{ message: string, timestamp: number }> = [];
constructor() {
... |
097992871bd9f43902478883a988d02cf792ddb2 | TypeScript | cpsubrian/react-redux-zelda | /complete/src/data/actions.ts | 2.6875 | 3 | import {Action} from 'redux';
import {ThunkAction} from 'redux-thunk';
import {ActionTypes, LayerName, TileInstance, StoreState} from '../types';
/**
* Action object type definitions.
*/
export interface SelectTileType extends Action {
type: ActionTypes.SELECT_TILE_TYPE;
tileType: string;
}
export interface Un... |
cef7377d7fb0af0ff882720fdf1a26665a8bdbc8 | TypeScript | anoblet/my-project | /src/components/Pomodoro/Template.ts | 2.609375 | 3 | import { html } from "lit-element";
export default function() {
return html`
<div id="modes">
${modes.bind(this)()}
</div>
<div flex-grow>
<grid-component columns="2">
<span
><input name="minutes" type="text" value="${this._minutes}"
/></span>
<span
... |
89564cd065a42145883c26cbbadd589354ced116 | TypeScript | HongAnhDo/datn_api | /app/service/vehicle/OptionService.ts | 2.671875 | 3 | import { cx_vhc_opt as OptionVehicle } from "../../entities/vehicle/cx_vhc_opt";
import OptionRepository from "../../repository/vehicle/option/OptionRepository";
export default interface IOptionService {
getAll(): Promise<Array<OptionVehicle>>
getOne(id: number): Promise<OptionVehicle>
create(optionVehicle... |
ceae664ac0195bf5cafedbf8f22cf1bcc9fce93d | TypeScript | mullet1989/strava-cups | /src/entity/athlete.accesstoken.entity.ts | 2.5625 | 3 | import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from 'typeorm';
import { Athlete } from './athlete.entity';
@Entity('athlete_access_token')
export class AthleteAccessToken {
@PrimaryGeneratedColumn()
id: number;
@Column()
access_token: string;
@Column()
refresh_token: string;
... |
6b7e0567f43c0b32f112cedc8ad2fd7a916bd800 | TypeScript | ChiriVulpes/weaving-old | /src/Util.ts | 3.171875 | 3 | export function padLeft (str: string, len: number, pad: string) {
while (str.length < len) str = pad + str;
return str;
}
export function padRight (str: string, len: number, pad: string) {
while (str.length < len) str += pad;
return str;
}
export function capitalize (str: string, offset = 0) {
return (offset > 0 ?... |
c5cd5ae54aa7bc7066296bf357a8f20ce24f1d7d | TypeScript | EnochGao/typescript-design-patterns | /src/structural-pattern/adapter/adapter.ts | 3.75 | 4 | // 将一个类的接口转换成客户希望的另外一个接口。Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作
/**
* 目标(Target)接口:当前系统业务所期待的接口,它可以是抽象类或接口。
适配者(Adaptee)类:它是被访问和适配的现存组件库中的组件接口。
适配器(Adapter)类:它是一个转换器,通过继承或引用适配者的对象,把适配者接口转换成目标接口,让客户按目标接口的格式访问适配者。
*/
export interface ITarget {
request(): void;
}
export class Adaptee {
specificRequ... |
f8e14ab07da51e91983f8a84109b20bb69f67741 | TypeScript | altoplano/backchannel | /src/crypto.ts | 2.75 | 3 | import { Key, DiscoveryKey } from './types';
import { Buffer } from 'buffer';
export type EncryptedProtocolMessage = {
cipher: string;
nonce: string;
};
export async function generateKey(): Promise<Key> {
let rawKey = await window.crypto.subtle.generateKey(
{
name: 'AES-GCM',
length: 256,
},... |