repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
AlmirJNR/Desafio-CI-T
DevelopmentTest/backend_nodejs/src/controllers/APIv1/ToDoController/Put.ts
import { Router } from 'express'; import { updateToDoById, updateToDoTextById, updateToDoFinishedById, updateToDoIsDateCreatedById, updateToDoIsDateFinishedById, } from '@/services/ToDoService/Put'; const router = Router(); /** PUT: update all toDo information by id */ router.put('/:id', async (request, re...
AlmirJNR/Desafio-CI-T
DevelopmentTest/backend_nodejs/database/migrations/20211205224817_Initial.ts
import { Knex } from 'knex'; export async function up(knex: Knex): Promise<void> { return knex.schema.raw( `CREATE TABLE IF NOT EXISTS todos( id serial PRIMARY KEY, text text NOT NULL, finished boolean NOT NULL, date_created timestamp NOT NULL, date_finished timestamp )`, ); }...
AlmirJNR/Desafio-CI-T
DevelopmentTest/backend_nodejs/src/Server.ts
import cors from 'cors'; import dotenv from 'dotenv'; import express from 'express'; import helmet from 'helmet'; // Import default controllers and routers import APIv1Router from '@/controllers/APIv1Router'; // Load the .env dotenv.config(); /** Set up an instance of express server */ const server = express(); // ...
AlmirJNR/Desafio-CI-T
DevelopmentTest/backend_nodejs/src/controllers/APIv1/ToDoControllerRouter.ts
import { Router } from 'express'; import ToDoGet from '@/controllers/APIv1/ToDoController/Get'; import ToDoPost from '@/controllers/APIv1/ToDoController/Post'; import ToDoPut from '@/controllers/APIv1/ToDoController/Put'; import ToDoDelete from '@/controllers/APIv1/ToDoController/Delete'; const router = Router(); //...
AlmirJNR/Desafio-CI-T
DevelopmentTest/backend_nodejs/test/Server.spec.ts
import { describe, it } from 'mocha'; import request from 'supertest'; import Server from '@/Server'; describe('Testing if api is running', () => { it('should respond with a default message', (done) => { request(Server) .get('/') .expect(200, { message: 'Almir Junior ToDo List Default Api Re...
AlmirJNR/Desafio-CI-T
DevelopmentTest/backend_nodejs/src/index.ts
<filename>DevelopmentTest/backend_nodejs/src/index.ts import Server from '@/Server'; const port = Number(process.env.EXPRESS_PORT) || 8080; // Start the server on the specified port Server.listen(port, () => { console.info(`Server is up and listening on 'http://localhost:${port}'`); });
AlmirJNR/Desafio-CI-T
DevelopmentTest/backend_nodejs/src/types/model/ToDo.d.ts
<gh_stars>0 export interface ToDo { id?: number, text?: string, finished?: boolean, dateCreated?: Date, dateFinished?: Date, }
Emad-Darabeh/cognito-auth
src/user/user.controller.ts
<filename>src/user/user.controller.ts<gh_stars>0 import { Controller, Get, Param, UseGuards } from '@nestjs/common'; import { User } from './user.entity'; import { UserService } from './user.service'; import { AuthGuard } from '@nestjs/passport'; @Controller('users') export class UserController { constructor(private...
Emad-Darabeh/cognito-auth
src/user/user.entity.ts
import { Entity, PrimaryColumn, CreateDateColumn, BaseEntity, Column, } from 'typeorm'; @Entity('user') export class User extends BaseEntity { @PrimaryColumn('uuid') id: string; @Column() username: string; @Column({ default: false }) isVerified: boolean; @CreateDateColumn() createdAt?: Date;...
Emad-Darabeh/cognito-auth
src/user/user.service.ts
import { Injectable, HttpException, HttpStatus, NotFoundException, } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { CreateUserDto } from './dto/create-user.dto'; import { User } from './user.entity'; import { UserRepository } from './user.repository'; @Injectable() export c...
Emad-Darabeh/cognito-auth
src/auth/auth.service.ts
import { AuthConfig } from './auth.config'; import { Inject, Injectable } from '@nestjs/common'; import { AuthenticationDetails, CognitoUser, CognitoUserPool, CognitoUserAttribute, ICognitoUserData, } from 'amazon-cognito-identity-js'; import { UserService } from 'src/user/user.service'; @Injectable() export...
Emad-Darabeh/cognito-auth
src/auth/auth.controller.ts
import { BadRequestException, Body, Controller, Get, Post, Query } from "@nestjs/common"; import { AuthService } from './auth.service'; @Controller('auth') export class AuthController { constructor(private readonly authService: AuthService) {} @Post('register') async register( @Body() registerRequest: {...
wand2016/twitch_host_prototype
__tests__/Infrastructure/GoogleCalendarGatewayImpl.spec.ts
import GoogleCalendarGatewayImpl from "@app/Infrastructure/GoogleCalendarGatewayImpl"; import MyGlobal from "@tests/global"; import TYPES from "@app/types"; declare const global: MyGlobal; test("fetchEvents/OK", async () => { const googleCalendarGatewayImpl = global.container.get<GoogleCalendarGatewayImpl>(TYPES.Go...
wand2016/twitch_host_prototype
__tests__/Domain/HostReservation.spec.ts
import HostReservation from "@app/Domain/HostReservation"; import DatetimeRange from "@app/Domain/DatetimeRange"; test("getStreamerAccountName/構築時に指定したアカウント名を得る", () => { const streamerAccountName = "an_awesome_account"; const hostReservation = new HostReservation( streamerAccountName, new DatetimeRange( ...
wand2016/twitch_host_prototype
__tests__/Infrastructure/HostReservationRepositoryImpl.spec.ts
import HostReservationRepositoryImpl from "@app/Infrastructure/HostReservationRepositoryImpl"; import MyGlobal from "@tests/global"; import TYPES from "@app/types"; import GoogleCalendarGatewayFake from "@app/Infrastructure/GoogleCalendarGatewayFake"; import events from "@tests/sample/events"; import GoogleCalendarGate...
wand2016/twitch_host_prototype
__tests__/handler.spec.ts
import { entrypoint } from "@app/handler"; test('hoge', async (done) => { await entrypoint(); done(); });
wand2016/twitch_host_prototype
src/Domain/TwitchCommandExecuter.ts
<reponame>wand2016/twitch_host_prototype "use strict"; export default interface TwitchCommandExecuter { host(streamerAccountName: string): Promise<void>; unhost(): Promise<void>; }
wand2016/twitch_host_prototype
src/Infrastructure/TwitchCommandExecuterImpl.ts
"use strict"; import TwitchCommandExecuter from "@app/Domain/TwitchCommandExecuter"; import tmi from "tmi.js"; import { injectable } from "inversify"; @injectable() export default class TwitchCommandExecuterImpl implements TwitchCommandExecuter { /** * @readonly */ private ircClient: tmi.Client; /** ...
wand2016/twitch_host_prototype
__tests__/sample/events.ts
import { calendar_v3 } from "googleapis"; const events: calendar_v3.Schema$Event[] = [ { kind: "calendar#event", etag: "\"3156279976436000\"", id: "47vle5jario2uhsc34mk1haiep", status: "confirmed", htmlLink: "", created: "2020-01-01T12:13:08.000Z", updated: "2020-01-01T12:13:08.218Z", ...
wand2016/twitch_host_prototype
__tests__/Domain/DatetimeRange.spec.ts
<filename>__tests__/Domain/DatetimeRange.spec.ts<gh_stars>0 import DatetimeRange from "@app/Domain/DatetimeRange"; import each from "jest-each"; each([ [ new Date("2020-01-01T00:00:00+09:00"), new Date("2020-01-03T00:00:00+09:00"), new Date("2019-12-31T00:00:00+09:00"), false, ], [ new Date("...
wand2016/twitch_host_prototype
src/Infrastructure/GoogleCalendarGatewayFake.ts
"use strict"; import { calendar_v3 } from "googleapis"; import GoogleCalendarGateway from "@app/Infrastructure/GoogleCalendarGateway"; import { injectable } from "inversify"; @injectable() export default class GoogleCalendarGatewayFake implements GoogleCalendarGateway { constructor(private events: calendar_v3.Sche...
wand2016/twitch_host_prototype
src/Domain/DatetimeRange.ts
"use strict"; export default class DatetimeRange { constructor( private begin: Date, private end: Date, ) { } public contains(datetime: Date): boolean { return this.begin <= datetime && datetime <= this.end; } }
wand2016/twitch_host_prototype
__tests__/sample/event.ts
import { calendar_v3 } from "googleapis"; const event: calendar_v3.Schema$Event = { kind: "calendar#event", etag: "\"3156279976436000\"", id: "47vle5jario2uhsc34mk1haiep", status: "confirmed", htmlLink: "https://www.google.com/calendar/event?eid=NDd2bGU1amFyaW8ydWhzYzM0bWsxaGFpZXAgdHdpdGNoLmhvc3Rpbmcuc3JAbQ"...
wand2016/twitch_host_prototype
src/Mappers/HostReservationMapper.ts
<reponame>wand2016/twitch_host_prototype "use strict"; import { calendar_v3 } from "googleapis"; import HostReservation from "@app/Domain/HostReservation"; import DatetimeRange from "@app/Domain/DatetimeRange"; import { injectable } from "inversify"; @injectable() export default class HostReserationMapper { public ...
wand2016/twitch_host_prototype
__tests__/jest.setup.ts
<gh_stars>0 import dotenv from "dotenv"; dotenv.config(); import container from "@app/inversify.config"; import TestGlobal from "@tests/global"; declare const global:TestGlobal; global.container = container;
wand2016/twitch_host_prototype
src/Infrastructure/GoogleCalendarGatewayImpl.ts
"use strict"; import { google, calendar_v3 } from "googleapis"; import { JWT } from "google-auth-library"; import { injectable } from "inversify"; import GoogleCalendarGateway from "@app/Infrastructure/GoogleCalendarGateway"; @injectable() export default class GoogleCalendarGatewayImpl implements GoogleCalendarGatewa...
wand2016/twitch_host_prototype
__tests__/Infrastructure/TwitchCommandExecuterFake.spec.ts
import TwitchCommandExecuterFake from "@app/Infrastructure/TwitchCommandExecuterFake"; test("host/executedHostがtrueになる", async () => { const twitchCommandExecuterFake = new TwitchCommandExecuterFake(); expect(twitchCommandExecuterFake.executedHost).toBe(false); await twitchCommandExecuterFake.host("wand_ta"); ...
wand2016/twitch_host_prototype
src/Domain/HostReservationRepository.ts
"use strict"; import HostReservation from "@app/Domain/HostReservation"; import SearchCriteria from "@app/Domain/SearchCriteria"; export default interface HostReservationRepository { matched(searchCriteria: SearchCriteria): Promise<HostReservation[]>; }
wand2016/twitch_host_prototype
src/Infrastructure/HostReservationRepositoryImpl.ts
"use strict"; import HostReservationRepository from "@app/Domain/HostReservationRepository"; import SearchCriteria from "@app/Domain/SearchCriteria"; import HostReservation from "@app/Domain/HostReservation"; import HostReserationMapper from "@app/Mappers/HostReservationMapper"; import { inject, injectable } from "inv...
wand2016/twitch_host_prototype
src/Domain/HostReservation.ts
"use strict"; import DatetimeRange from "@app/Domain/DatetimeRange"; export default class HostReservation { constructor( private streamerAccountName: string, private datetimeRange: DatetimeRange, private updatedAt: Date, ) { } public getStreamerAccountName(): string { return this.streamerAccou...
wand2016/twitch_host_prototype
__tests__/Infrastructure/GoogleCalendarGatewayFake.spec.ts
import GoogleCalendarGatewayFake from "@app/Infrastructure/GoogleCalendarGatewayFake"; import event from "@tests/sample/event"; test("fetchEvents/構築時に指定したeventsを得る", async () => { const eventsExpected = [event, event]; const googleCalendarGatewayFake = new GoogleCalendarGatewayFake(eventsExpected); const events...
wand2016/twitch_host_prototype
src/types.ts
const TYPES = { AutoHosting: Symbol.for("AutoHosting"), HostReservationRepository: Symbol.for("HostReservationRepository"), HostReservationRepositoryImpl: Symbol.for("HostReservationRepositoryImpl"), GoogleCalendarGateway: Symbol.for("GoogleCalendarGateway"), GoogleCalendarGatewayImpl: Symbol.for("GoogleCalen...
wand2016/twitch_host_prototype
src/Infrastructure/GoogleCalendarGateway.ts
"use strict"; import { calendar_v3 } from "googleapis"; export default interface GoogleCalendarGateway { fetchEvents( timeMax: Date, timeMin: Date, ): Promise<calendar_v3.Schema$Event[]>; }
wand2016/twitch_host_prototype
__tests__/Mappers/HostReservationMapper.spec.ts
<filename>__tests__/Mappers/HostReservationMapper.spec.ts import HostReservationMapper from "@app/Mappers/HostReservationMapper"; import event from "@tests/sample/event"; import HostReservation from "@app/Domain/HostReservation"; import DatetimeRange from "@app/Domain/DatetimeRange"; test("createFromGoogleCalendarEven...
wand2016/twitch_host_prototype
__tests__/Infrastructure/TwitchCommandExecuterImpl.spec.ts
import TwitchCommandExecuterImpl from "@app/Infrastructure/TwitchCommandExecuterImpl"; import MyGlobal from "@tests/global"; import TYPES from "@app/types"; declare const global: MyGlobal; test("host/OK", async (done) => { const twitchCommandExecuterImpl = global.container.get<TwitchCommandExecuterImpl>(TYPES.Twitc...
wand2016/twitch_host_prototype
__tests__/Domain/SearchCriteria.spec.ts
import SearchCriteria from "@app/Domain/SearchCriteria"; test("getDatetime/構築時に指定した値を得る", () => { const datetime = new Date("2020-01-01T00:00:00+09:00"); const searchCriteria = new SearchCriteria(datetime); expect(searchCriteria.getDatetime()).toBe(datetime); });
wand2016/twitch_host_prototype
__tests__/Services/AutoHosting.spec.ts
import AutoHosting from "@app/Services/AutoHosting"; import GoogleCalendarGatewayFake from "@app/Infrastructure/GoogleCalendarGatewayFake"; import GoogleCalendarGateway from "@app/Infrastructure/GoogleCalendarGateway"; import TwitchCommandExecutor from "@app/Domain/TwitchCommandExecuter"; import TwitchCommandExecutorFa...
wand2016/twitch_host_prototype
src/Services/AutoHosting.ts
<reponame>wand2016/twitch_host_prototype<filename>src/Services/AutoHosting.ts "use strict"; import TYPES from "@app/types"; import { inject, injectable } from "inversify"; import HostReservationRepository from "@app/Domain/HostReservationRepository"; import TwitchCommandExecuter from "@app/Domain/TwitchCommandExecuter...
wand2016/twitch_host_prototype
src/Infrastructure/TwitchCommandExecuterFake.ts
<filename>src/Infrastructure/TwitchCommandExecuterFake.ts "use strict"; import TwitchCommandExecuter from "@app/Domain/TwitchCommandExecuter"; import { injectable } from "inversify"; @injectable() export default class TwitchCommandExecuterFake implements TwitchCommandExecuter { public executedHost = false; publi...
wand2016/twitch_host_prototype
__tests__/global.d.ts
<reponame>wand2016/twitch_host_prototype<gh_stars>0 import Global = NodeJS.Global; import { Container } from "inversify"; export default interface TestGlobal extends Global { container: Container }
wand2016/twitch_host_prototype
src/inversify.config.ts
<reponame>wand2016/twitch_host_prototype import "reflect-metadata"; import { Container } from "inversify"; import TYPES from "@app/types"; import GoogleCalendarGateway from "@app/Infrastructure/GoogleCalendarGateway"; import GoogleCalendarGatewayImpl from "@app/Infrastructure/GoogleCalendarGatewayImpl"; import TwitchC...
wand2016/twitch_host_prototype
src/handler.ts
"use strict"; import container from "@app/inversify.config"; import AutoHosting from "@app/Services/AutoHosting"; import TYPES from "@app/types"; export const entrypoint = async () => { const autoHosting = container.get<AutoHosting>(TYPES.AutoHosting); await autoHosting.checkReservationAndHost(); return { ...
wand2016/twitch_host_prototype
src/Domain/SearchCriteria.ts
"use strict"; export default class SearchCriteria { constructor( private datetime: Date, ) { } public getDatetime(): Date { return this.datetime; } }
denolib/test-bot
src/index.ts
import { Application, Context } from "probot"; // eslint-disable-line no-unused-vars import git from "simple-git/promise"; import rimraf from "rimraf"; import { system, deferred } from "./utils"; import { execSync } from "child_process"; import { mkdirSync, exists } from "fs"; import { promisify } from "util"; functio...
denolib/test-bot
src/utils.ts
import { exec } from "child_process"; export interface Deferred<T> extends Promise<T> { resolve: (value?: T | PromiseLike<T>) => void; reject: (reason?: any) => void; } export function deferred<T>(): Deferred<T> { let methods; const promise = new Promise<T>( (resolve, reject): void => { methods = { ...
denolib/test-bot
lib/utils.d.ts
<filename>lib/utils.d.ts<gh_stars>0 export interface Deferred<T> extends Promise<T> { resolve: (value?: T | PromiseLike<T>) => void; reject: (reason?: any) => void; } export declare function deferred<T>(): Deferred<T>; interface SystemOutput { code: number; stdout: string; stderr: string; error:...
amg-web/alpine-chrome
with-deno/src/helloworld.ts
import { bgBlue, red, bold } from "https://deno.land/std/fmt/colors.ts"; console.log(bgBlue(red(bold("Hello world!"))));
magnitronus/ngx-social-auth
src/lib/auth_providers/google.provider.ts
<filename>src/lib/auth_providers/google.provider.ts<gh_stars>0 import {BaseSocialAuthProvider} from "./_base.provider"; declare let gapi: any; export class GoogleAuthProvider extends BaseSocialAuthProvider { gauth: any; static load(config: {clientId: string, scopes?: string[]}) { let d = document, gJs, ref:...
magnitronus/ngx-social-auth
src/demo/app.component.ts
import { Component } from '@angular/core'; @Component({ selector: 'yal-demo', styleUrls: ['./app.component.scss'], templateUrl: './app.component.html', }) export class AppComponent { something = 'Hello world!'; log(message: any): void { console.log(message); } }
magnitronus/ngx-social-auth
src/lib/auth_providers/facebook.provider.ts
<reponame>magnitronus/ngx-social-auth import {BaseSocialAuthProvider} from "./_base.provider"; declare let FB: any; export class FacebookAuthProvider extends BaseSocialAuthProvider { static load(config: {appId: string, apiVersion: string}) { let d = document, fbJs, id = 'facebook-jssdk', ref: any = d.getElemen...
magnitronus/ngx-social-auth
src/lib/interfaces.ts
export interface ISocialAuthProvider { auth: () => void; }
magnitronus/ngx-social-auth
src/lib/auth_providers/twitter.provider.ts
import {BaseSocialAuthProvider} from "./_base.provider"; import {Observable} from "rxjs/Observable"; import {Subject} from "rxjs/Subject"; export class TwitterAuthProvider extends BaseSocialAuthProvider { static authUrl: string = ''; static load(config: {authUrl: string}) { TwitterAuthProvider.authUrl = confi...
magnitronus/ngx-social-auth
src/lib/auth_providers/_base.provider.ts
import {ISocialAuthProvider} from "../interfaces"; import {Observer} from "rxjs/Observer"; export abstract class BaseSocialAuthProvider implements ISocialAuthProvider { constructor(protected authObserver: Observer<any>) { } static load(...args: any[]) { } auth() { throw "Please implement auth() metho...
magnitronus/ngx-social-auth
src/lib/services/social-auth.service.ts
<reponame>magnitronus/ngx-social-auth<gh_stars>0 import { Injectable } from '@angular/core'; import {SOCIAL_AUTH_PROVIDERS, SocialAuthProvider} from "../auth_providers/index"; import {Observable} from "rxjs/Observable"; @Injectable() export class SocialAuthService { constructor() { } auth(provider_name: SocialAu...
magnitronus/ngx-social-auth
src/lib/auth_providers/vk.provider.ts
<gh_stars>0 import {BaseSocialAuthProvider} from "./_base.provider"; declare let VK: any; export class VkAuthProvider extends BaseSocialAuthProvider { static load(config: {appId: string}) { let d = document, vkJs, id = 'vk-jssdk', ref: any = d.getElementsByTagName('script')[0]; vkJs = d.createElement('scri...
magnitronus/ngx-social-auth
src/lib/ngx-social-auth.ts
import { NgModule, ModuleWithProviders } from '@angular/core'; import {SocialAuthService} from "./services/social-auth.service"; import {SOCIAL_AUTH_PROVIDERS} from "./auth_providers/index"; import './auth_providers'; @NgModule({ }) export class SocialAuthModule { static forRoot(config: any): ModuleWithProviders {...
magnitronus/ngx-social-auth
src/lib/index.ts
<gh_stars>0 // import needed polyfills for the library // i.e. import 'rxjs/add/operator/map'; // export main module export { SocialAuthModule } from './ngx-social-auth'; export { SocialAuthService } from './services/social-auth.service'; export { SocialAuthProvider } from './auth_providers'; // export all components/...
magnitronus/ngx-social-auth
src/lib/auth_providers/index.ts
import {GoogleAuthProvider} from "./google.provider"; import {FacebookAuthProvider} from "./facebook.provider"; import {TwitterAuthProvider} from "./twitter.provider"; import {VkAuthProvider} from "./vk.provider"; function strEnum<T extends string>(o: Array<T>): {[K in T]: K} { return o.reduce((res, key) => { re...
burevestnikapp/arwen
local_peer_model.ts
type NetworkTime = number type NetworkID = string type NetworkMessage = string // interface GoMeshAPI { // is now separated into Swifts APIFuncs and APICallbacks // GetMyID(): string // SendMessage(id: string, data: string): void // RegisterMessageHandler(callback: (id: NetworkID, data: NetworkMessage) => void):...
nabby27/UseJS
src/test/date/relativeTime.spec.ts
import { relativeTime } from '../../app'; import { mockDate } from '../mocks/currentDateMock'; import { Locale } from '../../app/date/types/locale'; const currentDayMock = 27; const currentMonthMock = 5; const currentYearMock = 1996; const currentDateMock = new Date(currentYearMock, currentMonthMock, currentDayMock); ...
nabby27/UseJS
src/app/string/kebabCase.ts
<filename>src/app/string/kebabCase.ts /** * * @memberof module:String * @function kebabCase * * @description Returns the kebabCase text from text * * @param {!string} text - The text * @returns {strign} The kebabCase text * * @example * import { kebabCase } from 'main-fns'; * * const text = '<NAME>'; * co...
nabby27/UseJS
src/app/math/sum.ts
/** * * @memberof module:Math * @function sum * * @description Returns the sum from numbers * * @param {!number[]} numbers - The numbers * @returns {number} The sum * * @example * import { sum } from 'main-fns'; * * const numbers = [3, 1, 5]; * console.log(sum(numbers)); // 9 */ export function sum(...nu...
nabby27/UseJS
src/test/array/reverse.spec.ts
<gh_stars>1-10 import { reverse } from '../../app'; const data: { array: unknown[]; expect: unknown[]; }[] = [ { array: [3, 2, 1], expect: [1, 2, 3] }, { array: ['a', 'b', 'c'], expect: ['c', 'b', 'a'] } ]; describe('Get array reversed', () => { data.forEach...
nabby27/UseJS
src/test/math/mean.spec.ts
<reponame>nabby27/UseJS<filename>src/test/math/mean.spec.ts import { mean } from '../../app'; const data: { array: number[]; expect: number; }[] = [ { array: [3, 1, 2], expect: 2 }, { array: [4, 6, 2, 5], expect: 4.25 } ]; describe('Get mean from array', () => {...
nabby27/UseJS
src/app/math/index.ts
<reponame>nabby27/UseJS<gh_stars>1-10 /** @module Math */ export * from './max'; export * from './mean'; export * from './median'; export * from './min'; export * from './mode'; export * from './multiply'; export * from './sum';
nabby27/UseJS
src/app/date/endOfDay.ts
<filename>src/app/date/endOfDay.ts /** * * @memberof module:Date * @function endOfDay * * @description Get the date you pass with time to 23:59:59:999 * * @param {Date} [date=new Date()] - The date * @returns {!Date} - The date with end time, by default is `new Date()` * * @example * import { endOfDay } from...
nabby27/UseJS
src/test/string/camelCase.spec.ts
<filename>src/test/string/camelCase.spec.ts import { camelCase } from '../../app'; const data: { text: string; expect: string; }[] = [ { text: 'hello world', expect: 'helloWorld' }, { text: 'bYE', expect: 'bye' } ]; describe('Get camelCase text', () => { dat...
nabby27/UseJS
src/test/array/last.spec.ts
import { last } from '../../app'; const data: { array: unknown[]; expect: unknown; }[] = [ { array: [3, 2, 1], expect: 1 }, { array: ['a', 'b', 'c'], expect: 'c' } ]; describe('Get last item from array', () => { data.forEach((item) => { test('should ...
nabby27/UseJS
src/test/object/clone.spec.ts
import { clone } from '../../app'; const data: { user: { name: string, alias: string }, links: string[] }[] = [ { user: { name: 'Iván', alias: 'nabby27' }, links: [ 'https://icordoba.es', 'https://github.com/nabby27...
nabby27/UseJS
src/app/string/upperCase.ts
/** * * @memberof module:String * @function upperCase * * @description Returns the upperCase text from text * * @param {!string} text - The text * @returns {strign} The upperCase text * * @example * import { upperCase } from 'main-fns'; * * const text = '<NAME>'; * console.log(upperCase(text)); // 'HELLO ...
nabby27/UseJS
src/app/string/index.ts
/** @module String */ export * from './camelCase'; export * from './capitalize'; export * from './firstLetters'; export * from './kebabCase'; export * from './lastLetters'; export * from './lowerCase'; export * from './pascalCase'; export * from './snakeCase'; export * from './titleCase'; export * from './upperCase';
nabby27/UseJS
src/app/date/subtractMonths.ts
<filename>src/app/date/subtractMonths.ts /** * * @memberof module:Date * @function subtractMonths * * @description Returns the date with the subtract of the months, by default the date is `new Date()` * * @param {!number} monthsToSubtract - The number of months to subtract * @param {Date} [date=new Date()] - Th...
nabby27/UseJS
src/test/object/isEqual.spec.ts
import { isEqual } from '../../app'; const data: { first: { user: { name: string } }, second: { user: { name: string } }, expect: boolean }[] = [ { first: { user: { name: 'Iván' } }, second: { user: { name: 'Iván' } }, expect: true }, ...
nabby27/UseJS
src/app/date/addYears.ts
/** * * @memberof module:Date * @function addYears * * @description Returns the date with the sum of the years, by default the date is `new Date()` * * @param {!number} yearsToAdd - The number of years to increase * @param {Date} [date=new Date()] - The date to which years are added, by default is `new Date()` ...
nabby27/UseJS
src/app/math/mode.ts
<reponame>nabby27/UseJS /** * * @memberof module:Math * @function mode * * @description Returns the mode from numbers * * @param {!number[]} numbers - The numbers * @returns {number} The mode * * @example * import { mode } from 'main-fns'; * * const numbers = [3, 1, 5, 1]; * console.log(mode(numbers)); //...
nabby27/UseJS
src/test/date/startOfDay.spec.ts
import { startOfDay } from '../../app'; import { mockDate } from '../mocks/currentDateMock'; const currentDayMock = 27; const currentMonthMock = 5; const currentYearMock = 1996; const currentDateMock = new Date(currentYearMock, currentMonthMock, currentDayMock); const expectsDates: { date?: Date; expect: Date...
nabby27/UseJS
src/app/date/subtractYears.ts
<filename>src/app/date/subtractYears.ts /** * * @memberof module:Date * @function subtractYears * * @description Returns the date with the subtract of the years, by default the date is `new Date()` * * @param {!number} yearsToSubtract - The number of years to subtract * @param {Date} [date=new Date()] - The dat...
nabby27/UseJS
src/app/date/addDays.ts
<reponame>nabby27/UseJS /** * * @memberof module:Date * @function addDays * * @description Returns the date with the sum of the days, by default the date is `new Date()` * * @param {!number} daysToAdd - The number of days to increase * @param {Date} [date=new Date()] - The date to which days are added, by defau...
nabby27/UseJS
src/app/math/median.ts
/** * * @memberof module:Math * @function median * * @description Returns the median from numbers * * @param {!number[]} numbers - The numbers * @returns {number} The median * * @example * import { median } from 'main-fns'; * * const numbers = [3, 1, 5]; * console.log(median(numbers)); // 3 */ export fun...
nabby27/UseJS
src/test/string/lastLetters.spec.ts
<gh_stars>1-10 import { lastLetters } from '../../app'; const data: { text: string; numberOfLetters?: number, expect: string; }[] = [ { text: 'hello', expect: 'o' }, { text: 'bYE', numberOfLetters: 2, expect: 'ye' } ]; describe('Get last letters', ()...
nabby27/UseJS
src/app/math/mean.ts
<filename>src/app/math/mean.ts<gh_stars>1-10 /** * * @memberof module:Math * @function mean * * @description Returns the mean from numbers * * @param {!number[]} numbers - The numbers * @returns {number} The mean * * @example * import { mean } from 'main-fns'; * * const numbers = [3, 1, 5]; * console.log(...
nabby27/UseJS
src/test/date/isBefore.spec.ts
import { isBefore } from '../../app'; const expectsIsBefore: { date: Date; dateToCompare: Date; expect: boolean; }[] = [ { date: new Date(2020, 10, 13), dateToCompare: new Date(2020, 10, 14), expect: true }, { date: new Date(2020, 10, 14), dateToCompare: ...
nabby27/UseJS
src/app/date/relativeTime.ts
import { Locale } from './types/locale'; /** * * @memberof module:Date * @function relativeTime * * @description Returns the relative time from date * * @param {!Date} date - The date to compare relative time * @param {Locale} [locale='en-US'] - The locale to return string, by default is `'en-US'` * @returns ...
nabby27/UseJS
src/test/string/pascalCase.spec.ts
import { pascalCase } from '../../app'; const data: { text: string; expect: string; }[] = [ { text: 'HELLO world', expect: 'HelloWorld' }, { text: 'good bye', expect: 'GoodBye' } ]; describe('Get pascalCase text', () => { data.forEach((item) => { tes...
nabby27/UseJS
src/test/math/max.spec.ts
import { max } from '../../app'; const data: { array: number[]; expect: number; }[] = [ { array: [3, 1, 2], expect: 3 }, { array: [4, 6, 2, 5], expect: 6 } ]; describe('Get biggest number from array', () => { data.forEach((item) => { test('should ret...
nabby27/UseJS
src/test/date/dateToString.spec.ts
<filename>src/test/date/dateToString.spec.ts import { dateToString } from '../../app'; import { DateStringFormat } from '../../app/date/types/dateStringFormat'; const currentDay = new Date().getDate(); const currentMonth = new Date().getMonth(); const currentYear = new Date().getFullYear(); const expectsDatesToString...
nabby27/UseJS
src/test/string/upperCase.spec.ts
import { upperCase } from '../../app'; const data: { text: string; expect: string; }[] = [ { text: 'HELLO world', expect: 'HELLO WORLD' }, { text: 'good bye', expect: 'GOOD BYE' } ]; describe('Get upperCase text', () => { data.forEach((item) => { tes...
nabby27/UseJS
src/app/date/types/dateStringFormat.ts
/** * * @memberof module:Date * @typedef {'yyyy-MM-dd' | 'yyyy/MM/dd' | 'dd-MM-yyyy' | 'dd/MM/yyyy'} DateStringFormat * * @description String to format date. * * @name DateStringFormat * @alias DateStringFormat */ export type DateStringFormat = | 'yyyy-MM-dd' | 'yyyy/MM/dd' | 'dd-MM-yyyy' | 'dd/MM/yyyy...
nabby27/UseJS
src/app/array/reverse.ts
<gh_stars>1-10 /** * * @memberof module:Array * @function reverse * * @description Returns the array reversed * * @template T * @param {!T[]} array - The array * @returns {T[]} The array reversed * * @example * import { reverse } from 'main-fns'; * * const numbers = [3, 1, 5]; * console.log(reverse(numbe...
nabby27/UseJS
src/app/date/index.ts
<filename>src/app/date/index.ts /** @module Date */ export * from './addDays'; export * from './addMonths'; export * from './addYears'; export * from './dateToString'; export * from './endOfDay'; export * from './isAfter'; export * from './isBefore'; export * from './relativeTime'; export * from './startOfDay'; export...
nabby27/UseJS
src/test/date/substractYears.spec.ts
<filename>src/test/date/substractYears.spec.ts import { subtractYears } from '../../app'; const currentDay = new Date().getDate(); const currentMonth = new Date().getMonth(); const currentYear = new Date().getFullYear(); const expectsDates: { numberOfYearsToSubtract: number; date?: Date; expect: Date; }[]...
nabby27/UseJS
src/test/math/multiply.spec.ts
<gh_stars>1-10 import { multiply } from '../../app'; const data: { array: number[]; expect: number; }[] = [ { array: [3, 1, 2], expect: 6 }, { array: [4, 6, 2, 5], expect: 240 } ]; describe('Get product from numbers', () => { data.forEach((item) => { ...
nabby27/UseJS
src/app/date/addMonths.ts
<gh_stars>1-10 /** * * @memberof module:Date * @function addMonths * * @description Returns the date with the sum of the months, by default the date is `new Date()` * * @param {!number} monthsToAdd - The number of months to increase * @param {Date} [date=new Date()] - The date to which months are added, by defa...
nabby27/UseJS
src/app/date/subtractDays.ts
<reponame>nabby27/UseJS /** * * @memberof module:Date * @function subtractDays * * @description Returns the date with the subtract of the days, by default the date is `new Date()` * * @param {!number} daysToSubtract - The number of days to subtract * @param {Date} [date=new Date()] - The date to which days are ...
nabby27/UseJS
src/app/object/index.ts
<reponame>nabby27/UseJS<gh_stars>1-10 /** @module Object */ export * from './clone'; export * from './isEqual';
nabby27/UseJS
src/test/string/lowerCase.spec.ts
import { lowerCase } from '../../app'; const data: { text: string; expect: string; }[] = [ { text: 'HELLO wOrLd', expect: 'hello world' }, { text: 'Good Bye', expect: 'good bye' } ]; describe('Get lowerCase text', () => { data.forEach((item) => { tes...
nabby27/UseJS
src/app/string/titleCase.ts
<filename>src/app/string/titleCase.ts /** * * @memberof module:String * @function titleCase * * @description Returns the titleCase text from text * * @param {!string} text - The text * @returns {strign} The titleCase text * * @example * import { titleCase } from 'main-fns'; * * const text = '<NAME>'; * co...
nabby27/UseJS
src/test/date/endOfDay.spec.ts
<filename>src/test/date/endOfDay.spec.ts import { endOfDay } from '../../app'; import { mockDate } from '../mocks/currentDateMock'; const currentDayMock = 27; const currentMonthMock = 5; const currentYearMock = 1996; const currentDateMock = new Date(currentYearMock, currentMonthMock, currentDayMock); const expectsDat...
nabby27/UseJS
src/app/array/orderBy.ts
/** * * @memberof module:Array * @function orderBy * * @description Returns the the array ordered by key * * @template T * @param {!string} key - The key * @param {!T[]} array - The array * @returns {T[]} The array ordered by key * * @example * import { orderBy } from 'main-fns'; * * const users = [ * ...
nabby27/UseJS
src/test/string/kebabCase.spec.ts
import { kebabCase } from '../../app'; const data: { text: string; expect: string; }[] = [ { text: 'hello world', expect: 'hello-world' }, { text: 'Good Bye', expect: 'good-bye' } ]; describe('Get kebabCase text', () => { data.forEach((item) => { tes...