How to use valueSplits method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

add.command.ts

Source:add.command.ts Github

copy

Full Screen

1import {resolve} from 'path';2import {grey, green} from 'chalk';3import {pascalCase} from 'change-case';4const listGithubContent = require('list-github-dir-content');5import {OK, INFO} from '../../lib/services/message.service';6import {FileService} from '../../lib/services/file.service';7import {DownloadService} from '../../lib/services/download.service';8import {TerminalService} from '../../lib/services/terminal.service';9export class AddCommand {10 constructor(11 private fileService: FileService,12 private downloadService: DownloadService,13 private terminalService: TerminalService14 ) {}15 async run(input: string, params: string[] = []) {16 switch (input) {17 case 'component':18 case 'c':19 await this.addComponent(params[0]);20 break;21 case 'page':22 case 'p':23 await this.addPage(params[0]);24 break;25 default:26 await this.addAny(input);27 break;28 }29 }30 async addComponent(value: string) {31 this.terminalService.exec(32 `npx ng g c ${value} --skip-import`,33 '.',34 'inherit'35 );36 // add the '.module.ts'37 const valueSplits = value.split('/');38 const fileName = valueSplits[valueSplits.length - 1];39 const compName = pascalCase(fileName);40 await this.fileService.createFile(41 resolve('src', 'app', ...valueSplits, `${fileName}.module.ts`),42 [43 "import { NgModule } from '@angular/core';",44 "import { CommonModule } from '@angular/common';",45 '',46 `import { ${compName}Component } from './${fileName}.component';`,47 '',48 '@NgModule({',49 ` declarations: [${compName}Component],`,50 ' imports: [CommonModule],',51 ` exports: [${compName}Component]`,52 '})',53 `export class ${compName}ComponentModule {}`,54 '',55 ].join('\n')56 );57 }58 async addPage(value: string) {59 this.terminalService.exec(60 `npx ng g m ${value} --route ${value} --module app.module`,61 '.',62 'inherit'63 );64 // rename Component -> Page65 const valueSplits = value.split('/');66 const fileName = valueSplits[valueSplits.length - 1];67 const compName = pascalCase(fileName);68 // xxx-routing.component.ts69 await this.fileService.changeContent(70 resolve('src', 'app', ...valueSplits, `${fileName}-routing.module.ts`),71 {72 [`${compName}Component`]: `${compName}Page`,73 }74 );75 // xxx.component.ts76 await this.fileService.changeContent(77 resolve('src', 'app', ...valueSplits, `${fileName}.component.ts`),78 {79 [`${compName}Component`]: `${compName}Page`,80 }81 );82 // xxx.module.ts83 await this.fileService.changeContent(84 resolve('src', 'app', ...valueSplits, `${fileName}.module.ts`),85 {86 [`${compName}Component`]: `${compName}Page`,87 [`${compName}Module { }`]: `${compName}PageModule {}`,88 }89 );90 }91 async addAny(input: string) {92 let user!: string;93 let repository!: string;94 let directory!: string;95 // from @lamnhan/nguix-96 if (!input.startsWith('@')) {97 const [repoShortname, resourceGroup, resourceName] = input.split('/');98 user = 'lamnhan';99 repository = `nguix-${repoShortname}`;100 directory = `projects/${repoShortname}/src/lib/${resourceGroup}/${resourceName}`;101 }102 // from elsewhere103 else {104 const [org, repoName, resourceGroup, resourceName] = input.split('/');105 const repoShortname = repoName.replace('nguix-', '');106 user = org.replace('@', '');107 repository = repoName;108 directory = `projects/${repoShortname}/src/lib/${resourceGroup}/${resourceName}`;109 }110 // fetch list of files111 const fileList = (await listGithubContent.viaContentsApi({112 user,113 repository,114 directory,115 ref: 'main',116 })) as string[];117 const rawList = fileList.map(118 (dir: string) =>119 `https://raw.githubusercontent.com/${user}/${repository}/main/${dir}`120 );121 // download files122 const resultPaths = [] as string[];123 await Promise.all(124 rawList.map(rawUrl => {125 const filePath = rawUrl.split('/lib/').pop() as string;126 resultPaths.push(filePath);127 return this.downloadService.downloadText(128 rawUrl,129 resolve('src', 'app', ...filePath.split('/'))130 );131 })132 );133 // result134 console.log(135 INFO +136 'Resource from: ' +137 grey(`https://github.com/${user}/${repository}/tree/main/${directory}`)138 );139 resultPaths.forEach(path =>140 console.log(green('ADDED') + ` src/app/${path}`)141 );142 }...

Full Screen

Full Screen

EntitiesToIPv6.ts

Source:EntitiesToIPv6.ts Github

copy

Full Screen

1import { safeEndsWith, safeJoin, safeSlice, safeSplit, safeStartsWith, safeSubstring } from '../../../utils/globals';2/** @internal */3function readBh(value: string): string[] {4 if (value.length === 0) return [];5 else return safeSplit(value, ':');6}7/** @internal */8function extractEhAndL(value: string): [string[], string] {9 const valueSplits = safeSplit(value, ':');10 if (valueSplits.length >= 2 && valueSplits[valueSplits.length - 1].length <= 4) {11 // valueSplits[valueSplits.length - 1] is a h1612 // so we need to take the two last entries for l13 return [14 safeSlice(valueSplits, 0, valueSplits.length - 2),15 `${valueSplits[valueSplits.length - 2]}:${valueSplits[valueSplits.length - 1]}`,16 ];17 }18 return [safeSlice(valueSplits, 0, valueSplits.length - 1), valueSplits[valueSplits.length - 1]];19}20/** @internal */21export function fullySpecifiedMapper(data: [/*eh*/ string[], /*l*/ string]): string {22 return `${safeJoin(data[0], ':')}:${data[1]}`;23}24/** @internal */25export function fullySpecifiedUnmapper(value: unknown): [string[], string] {26 // Shape:27 // > 6( h16 ":" ) ls3228 if (typeof value !== 'string') throw new Error('Invalid type');29 return extractEhAndL(value);30}31/** @internal */32export function onlyTrailingMapper(data: [/*eh*/ string[], /*l*/ string]): string {33 return `::${safeJoin(data[0], ':')}:${data[1]}`;34}35/** @internal */36export function onlyTrailingUnmapper(value: unknown): [string[], string] {37 // Shape:38 // > "::" 5( h16 ":" ) ls3239 if (typeof value !== 'string') throw new Error('Invalid type');40 if (!safeStartsWith(value, '::')) throw new Error('Invalid value');41 return extractEhAndL(safeSubstring(value, 2));42}43/** @internal */44export function multiTrailingMapper(data: [/*bh*/ string[], /*eh*/ string[], /*l*/ string]): string {45 return `${safeJoin(data[0], ':')}::${safeJoin(data[1], ':')}:${data[2]}`;46}47/** @internal */48export function multiTrailingUnmapper(value: unknown): [string[], string[], string] {49 // Shape:50 // > [ h16 ] "::" 4( h16 ":" ) ls3251 // > [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls3252 // > [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls3253 // > [ *3( h16 ":" ) h16 ] "::" h16 ":" ls3254 if (typeof value !== 'string') throw new Error('Invalid type');55 const [bhString, trailingString] = safeSplit(value, '::', 2);56 const [eh, l] = extractEhAndL(trailingString);57 return [readBh(bhString), eh, l];58}59/** @internal */60export function multiTrailingMapperOne(data: [/*bh*/ string[], /*eh*/ string, /*l*/ string]): string {61 return multiTrailingMapper([data[0], [data[1]], data[2]]);62}63/** @internal */64export function multiTrailingUnmapperOne(value: unknown): [string[], string, string] {65 // Shape:66 // > [ *3( h16 ":" ) h16 ] "::" h16 ":" ls3267 const out = multiTrailingUnmapper(value);68 return [out[0], safeJoin(out[1], ':') /* nothing to join in theory */, out[2]];69}70/** @internal */71export function singleTrailingMapper(data: [/*bh*/ string[], /*l / eh*/ string]): string {72 return `${safeJoin(data[0], ':')}::${data[1]}`;73}74/** @internal */75export function singleTrailingUnmapper(value: unknown): [string[], string] {76 // Shape:77 // > [ *4( h16 ":" ) h16 ] "::" ls3278 // > [ *5( h16 ":" ) h16 ] "::" h1679 if (typeof value !== 'string') throw new Error('Invalid type');80 const [bhString, trailing] = safeSplit(value, '::', 2);81 return [readBh(bhString), trailing];82}83/** @internal */84export function noTrailingMapper(data: [/*bh*/ string[]]): string {85 return `${safeJoin(data[0], ':')}::`;86}87/** @internal */88export function noTrailingUnmapper(value: unknown): [string[]] {89 // Shape:90 // > [ *6( h16 ":" ) h16 ] "::"91 if (typeof value !== 'string') throw new Error('Invalid type');92 if (!safeEndsWith(value, '::')) throw new Error('Invalid value');93 return [readBh(safeSubstring(value, 0, value.length - 2))];...

Full Screen

Full Screen

format.js

Source:format.js Github

copy

Full Screen

1/**2 * 统一颜色的值3 * @param {*} value4 * @returns5 */6function formatColor(value) {7 if (value && value.indexOf('#') === 0) {8 // 统一转成小写9 value = value.toLocaleLowerCase();10 // #F2F => #FF22FF11 if (value.length === 4) {12 const valueSplits = value.substring(1).split('');13 return `#${valueSplits[0]}${valueSplits[0]}${valueSplits[1]}${valueSplits[1]}${valueSplits[2]}${valueSplits[2]}`;14 }15 }16 return value;17}18/**19 * 统一content的值20 * @param {*} value21 * @returns22 */23function formatContent(value) {24 if (value) {25 return value.replace(/\s+/g, '').replace(/["|']/g, '"');26 }27 return value;28}29/**30 * 统一将0rpx, 0px, 0Px, 0PX 转换 031 * @param {*} value32 * @returns33 */34function formatZero(value) {35 if (value) {36 value = value.toLocaleLowerCase();37 if (value === '0rpx' || value === '0px') return '0';38 return value;39 }40 return value;41}42const PropFormat = {43 color: formatColor,44 background: formatColor,45 'background-color': formatColor,46 content: formatContent,47 left: formatZero,48 right: formatZero,49 top: formatZero,50 bottom: formatZero,51 padding: formatZero,52 'padding-top': formatZero,53 'padding-bottom': formatZero,54 'padding-left': formatZero,55 'padding-right': formatZero,56 margin: formatZero,57 'margin-left': formatZero,58 'margin-right': formatZero,59 'margin-top': formatZero,60 'margin-bottom': formatZero,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful