Socket
Socket
Sign inDemoInstall

@nestia/e2e

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestia/e2e - npm Package Compare versions

Comparing version 0.1.8 to 0.2.0

17

lib/ArrayUtil.d.ts

@@ -7,11 +7,10 @@ /**

export declare namespace ArrayUtil {
function asyncFilter<Input>(elements: readonly Input[], pred: (elem: Input, index: number, array: readonly Input[]) => Promise<boolean>): Promise<Input[]>;
function asyncForEach<Input>(elements: readonly Input[], closure: (elem: Input, index: number, array: readonly Input[]) => Promise<any>): Promise<void>;
function asyncMap<Input, Output>(elements: readonly Input[], closure: (elem: Input, index: number, array: readonly Input[]) => Promise<Output>): Promise<Output[]>;
function asyncRepeat<T>(count: number, closure: (index: number) => Promise<T>): Promise<T[]>;
function has<T>(elements: readonly T[], pred: (elem: T) => boolean): boolean;
function repeat<T>(count: number, closure: (index: number) => T): T[];
function last<T>(array: T[]): T;
function flat<T>(matrix: T[][]): T[];
function subsets<T>(array: T[]): T[][];
const asyncFilter: <Input>(elements: readonly Input[]) => (pred: (elem: Input, index: number, array: readonly Input[]) => Promise<boolean>) => Promise<Input[]>;
const asyncForEach: <Input>(elements: readonly Input[]) => (closure: (elem: Input, index: number, array: readonly Input[]) => Promise<any>) => Promise<void>;
const asyncMap: <Input>(elements: readonly Input[]) => <Output>(closure: (elem: Input, index: number, array: readonly Input[]) => Promise<Output>) => Promise<Output[]>;
const asyncRepeat: (count: number) => <T>(closure: (index: number) => Promise<T>) => Promise<T[]>;
const has: <T>(elements: readonly T[]) => (pred: (elem: T) => boolean) => boolean;
const repeat: (count: number) => <T>(closure: (index: number) => T) => T[];
const flat: <T>(matrix: T[][]) => T[];
const subsets: <T>(array: T[]) => T[][];
}

@@ -83,4 +83,5 @@ "use strict";

(function (ArrayUtil) {
function asyncFilter(elements, pred) {
return __awaiter(this, void 0, void 0, function () {
var _this = this;
ArrayUtil.asyncFilter = function (elements) {
return function (pred) { return __awaiter(_this, void 0, void 0, function () {
var ret;

@@ -92,3 +93,3 @@ var _this = this;

ret = [];
return [4 /*yield*/, asyncForEach(elements, function (elem, index, array) { return __awaiter(_this, void 0, void 0, function () {
return [4 /*yield*/, ArrayUtil.asyncForEach(elements)(function (elem, index, array) { return __awaiter(_this, void 0, void 0, function () {
var flag;

@@ -111,10 +112,9 @@ return __generator(this, function (_a) {

});
});
}
ArrayUtil.asyncFilter = asyncFilter;
function asyncForEach(elements, closure) {
return __awaiter(this, void 0, void 0, function () {
}); };
};
ArrayUtil.asyncForEach = function (elements) {
return function (closure) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, asyncRepeat(elements.length, function (index) {
case 0: return [4 /*yield*/, ArrayUtil.asyncRepeat(elements.length)(function (index) {
return closure(elements[index], index, elements);

@@ -127,7 +127,6 @@ })];

});
});
}
ArrayUtil.asyncForEach = asyncForEach;
function asyncMap(elements, closure) {
return __awaiter(this, void 0, void 0, function () {
}); };
};
ArrayUtil.asyncMap = function (elements) {
return function (closure) { return __awaiter(_this, void 0, void 0, function () {
var ret;

@@ -139,3 +138,3 @@ var _this = this;

ret = [];
return [4 /*yield*/, asyncForEach(elements, function (elem, index, array) { return __awaiter(_this, void 0, void 0, function () {
return [4 /*yield*/, ArrayUtil.asyncForEach(elements)(function (elem, index, array) { return __awaiter(_this, void 0, void 0, function () {
var output;

@@ -157,7 +156,6 @@ return __generator(this, function (_a) {

});
});
}
ArrayUtil.asyncMap = asyncMap;
function asyncRepeat(count, closure) {
return __awaiter(this, void 0, void 0, function () {
}); };
};
ArrayUtil.asyncRepeat = function (count) {
return function (closure) { return __awaiter(_this, void 0, void 0, function () {
var indexes, output, indexes_1, indexes_1_1, index, _a, _b, e_1_1;

@@ -202,23 +200,19 @@ var e_1, _c;

});
});
}
ArrayUtil.asyncRepeat = asyncRepeat;
function has(elements, pred) {
return elements.find(pred) !== undefined;
}
ArrayUtil.has = has;
function repeat(count, closure) {
return new Array(count).fill("").map(function (_, index) { return closure(index); });
}
ArrayUtil.repeat = repeat;
function last(array) {
return array[array.length - 1];
}
ArrayUtil.last = last;
function flat(matrix) {
}); };
};
ArrayUtil.has = function (elements) {
return function (pred) {
return elements.find(pred) !== undefined;
};
};
ArrayUtil.repeat = function (count) {
return function (closure) {
return new Array(count).fill("").map(function (_, index) { return closure(index); });
};
};
ArrayUtil.flat = function (matrix) {
var _a;
return (_a = []).concat.apply(_a, __spreadArray([], __read(matrix), false));
}
ArrayUtil.flat = flat;
function subsets(array) {
};
ArrayUtil.subsets = function (array) {
var check = new Array(array.length).fill(false);

@@ -238,5 +232,4 @@ var output = [];

return output;
}
ArrayUtil.subsets = subsets;
};
})(ArrayUtil = exports.ArrayUtil || (exports.ArrayUtil = {}));
//# sourceMappingURL=ArrayUtil.js.map

@@ -13,3 +13,3 @@ /**

*/
function alphabets(length: number): string;
const alphabets: (length: number) => string;
/**

@@ -23,3 +23,3 @@ * Generate random alpha-numeric characters.

*/
function alphaNumeric(length: number): string;
const alphaNumeric: (length: number) => string;
/**

@@ -31,3 +31,3 @@ * Generate random name.

*/
function name(length?: number): string;
const name: (length?: number) => string;
/**

@@ -53,3 +53,3 @@ * Generate random paragraph.

*/
function substring(content: string): string;
const substring: (content: string) => string;
/**

@@ -60,16 +60,6 @@ * Generate random mobile number.

* @returns Random mobile number
* @example 010-334-0067
*/
function mobile(prefix?: string): string;
const mobile: (prefix?: string) => string;
/**
* Generate random digit.
*
* Generate random digit that filling front with zero characters
* when value is less than maximum cipher.
*
* @param minC Minimum cipher
* @param maxC Maximum cipher
* @returns
*/
function digit(minC: number, maxC: number): string;
/**
* Generate random date.

@@ -81,3 +71,3 @@ *

*/
function date(from: Date, range: number): Date;
const date: (from: Date) => (range: number) => Date;
/**

@@ -90,3 +80,3 @@ * Pick random elements from an array.

*/
function sample<T>(array: T[], count: number): T[];
const sample: <T>(array: T[]) => (count: number) => T[];
/**

@@ -98,3 +88,3 @@ * Pick random element from an array.

*/
function pick<T>(array: T[]): T;
const pick: <T>(array: T[]) => T;
}

@@ -24,3 +24,3 @@ "use strict";

*/
function alphabets(length) {
RandomGenerator.alphabets = function (length) {
return new Array(length)

@@ -30,4 +30,3 @@ .fill("")

.join("");
}
RandomGenerator.alphabets = alphabets;
};
/**

@@ -41,3 +40,3 @@ * Generate random alpha-numeric characters.

*/
function alphaNumeric(length) {
RandomGenerator.alphaNumeric = function (length) {
return new Array(length)

@@ -47,4 +46,3 @@ .fill("")

.join("");
}
RandomGenerator.alphaNumeric = alphaNumeric;
};
/**

@@ -56,7 +54,6 @@ * Generate random name.

*/
function name(length) {
RandomGenerator.name = function (length) {
if (length === void 0) { length = (0, tstl_1.randint)(2, 3); }
return RandomGenerator.paragraph(length)();
}
RandomGenerator.name = name;
};
/**

@@ -80,3 +77,3 @@ * Generate random paragraph.

.fill("")
.map(function () { return alphabets((0, tstl_1.randint)(wordMin, wordMax)); })
.map(function () { return RandomGenerator.alphabets((0, tstl_1.randint)(wordMin, wordMax)); })
.join(" ");

@@ -124,8 +121,7 @@ };

*/
function substring(content) {
RandomGenerator.substring = function (content) {
var first = (0, tstl_1.randint)(0, content.length - 1);
var last = (0, tstl_1.randint)(first + 1, content.length);
return content.substring(first, last).trim();
}
RandomGenerator.substring = substring;
};
/**

@@ -136,26 +132,16 @@ * Generate random mobile number.

* @returns Random mobile number
* @example 010-334-0067
*/
function mobile(prefix) {
RandomGenerator.mobile = function (prefix) {
if (prefix === void 0) { prefix = "010"; }
return "".concat(prefix).concat(digit(3, 4)).concat(digit(4, 4));
}
RandomGenerator.mobile = mobile;
return [
prefix,
(function () {
var value = (0, tstl_1.randint)(0, 9999);
return value.toString().padStart(value < 1000 ? 3 : 4, "0");
})(),
(0, tstl_1.randint)(0, 9999).toString().padStart(4, "0"),
].join("-");
};
/**
* Generate random digit.
*
* Generate random digit that filling front with zero characters
* when value is less than maximum cipher.
*
* @param minC Minimum cipher
* @param maxC Maximum cipher
* @returns
*/
function digit(minC, maxC) {
var val = (0, tstl_1.randint)(0, Math.pow(10.0, maxC) - 1);
var log10 = val ? Math.floor(Math.log10(val)) + 1 : 0;
var prefix = "0".repeat(Math.max(0, minC - log10));
return prefix + val.toString();
}
RandomGenerator.digit = digit;
/**
* Generate random date.

@@ -167,7 +153,7 @@ *

*/
function date(from, range) {
var time = from.getTime() + (0, tstl_1.randint)(0, range);
return new Date(time);
}
RandomGenerator.date = date;
RandomGenerator.date = function (from) {
return function (range) {
return new Date(from.getTime() + (0, tstl_1.randint)(0, range));
};
};
/**

@@ -180,8 +166,9 @@ * Pick random elements from an array.

*/
function sample(array, count) {
var ret = [];
(0, ranges_1.sample)(array, (0, tstl_1.back_inserter)(ret), count);
return ret;
}
RandomGenerator.sample = sample;
RandomGenerator.sample = function (array) {
return function (count) {
var ret = [];
(0, ranges_1.sample)(array, (0, tstl_1.back_inserter)(ret), count);
return ret;
};
};
/**

@@ -193,7 +180,6 @@ * Pick random element from an array.

*/
function pick(array) {
RandomGenerator.pick = function (array) {
return array[(0, tstl_1.randint)(0, array.length - 1)];
}
RandomGenerator.pick = pick;
};
})(RandomGenerator = exports.RandomGenerator || (exports.RandomGenerator = {}));
//# sourceMappingURL=RandomGenerator.js.map

@@ -16,3 +16,3 @@ /**

*/
function measure(task: Task): Promise<number>;
const measure: (task: Task) => Promise<number>;
/**

@@ -24,3 +24,3 @@ *

*/
function trace(title: string, task: Task): Promise<number>;
const trace: (title: string) => (task: Task) => Promise<number>;
}

@@ -47,2 +47,3 @@ "use strict";

(function (StopWatch) {
var _this = this;
/**

@@ -53,18 +54,15 @@ *

*/
function measure(task) {
return __awaiter(this, void 0, void 0, function () {
var time;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
time = Date.now();
return [4 /*yield*/, task()];
case 1:
_a.sent();
return [2 /*return*/, Date.now() - time];
}
});
StopWatch.measure = function (task) { return __awaiter(_this, void 0, void 0, function () {
var time;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
time = Date.now();
return [4 /*yield*/, task()];
case 1:
_a.sent();
return [2 /*return*/, Date.now() - time];
}
});
}
StopWatch.measure = measure;
}); };
/**

@@ -76,4 +74,4 @@ *

*/
function trace(title, task) {
return __awaiter(this, void 0, void 0, function () {
StopWatch.trace = function (title) {
return function (task) { return __awaiter(_this, void 0, void 0, function () {
var time;

@@ -84,3 +82,3 @@ return __generator(this, function (_a) {

process.stdout.write(" - ".concat(title, ": "));
return [4 /*yield*/, measure(task)];
return [4 /*yield*/, StopWatch.measure(task)];
case 1:

@@ -92,6 +90,5 @@ time = _a.sent();

});
});
}
StopWatch.trace = trace;
}); };
};
})(StopWatch = exports.StopWatch || (exports.StopWatch = {}));
//# sourceMappingURL=StopWatch.js.map

@@ -214,3 +214,3 @@ "use strict";

case 0:
samples = RandomGenerator_1.RandomGenerator.sample(total, sampleCount);
samples = RandomGenerator_1.RandomGenerator.sample(total)(sampleCount);
_loop_1 = function (s) {

@@ -217,0 +217,0 @@ var values, filtered, gotten;

{
"name": "@nestia/e2e",
"version": "0.1.8",
"version": "0.2.0",
"description": "E2E test utilify functions",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -6,3 +6,3 @@ # Nestia E2E Helper

[![Build Status](https://github.com/samchon/typia/workflows/build/badge.svg)](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)
[![Guide Documents](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://github.com/samchon/nestia/wiki)
[![Guide Documents](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://typia.io/docs/)

@@ -9,0 +9,0 @@ Helper library for E2E testing in NestJS.

/**
* Utility functions for arrays.
*
*
* @author Jeongho Nam - https://github.com/samchon
*/
export namespace ArrayUtil {
export async function asyncFilter<Input>(
elements: readonly Input[],
pred: (
elem: Input,
index: number,
array: readonly Input[],
) => Promise<boolean>,
): Promise<Input[]> {
const ret: Input[] = [];
await asyncForEach(elements, async (elem, index, array) => {
const flag: boolean = await pred(elem, index, array);
if (flag === true) ret.push(elem);
});
return ret;
}
export const asyncFilter =
<Input>(elements: readonly Input[]) =>
async (
pred: (
elem: Input,
index: number,
array: readonly Input[],
) => Promise<boolean>,
): Promise<Input[]> => {
const ret: Input[] = [];
await asyncForEach(elements)(async (elem, index, array) => {
const flag: boolean = await pred(elem, index, array);
if (flag === true) ret.push(elem);
});
return ret;
};
export async function asyncForEach<Input>(
elements: readonly Input[],
closure: (
elem: Input,
index: number,
array: readonly Input[],
) => Promise<any>,
): Promise<void> {
await asyncRepeat(elements.length, (index) =>
closure(elements[index], index, elements),
);
}
export const asyncForEach =
<Input>(elements: readonly Input[]) =>
async (
closure: (
elem: Input,
index: number,
array: readonly Input[],
) => Promise<any>,
): Promise<void> => {
await asyncRepeat(elements.length)((index) =>
closure(elements[index], index, elements),
);
};
export async function asyncMap<Input, Output>(
elements: readonly Input[],
closure: (
elem: Input,
index: number,
array: readonly Input[],
) => Promise<Output>,
): Promise<Output[]> {
const ret: Output[] = [];
await asyncForEach(elements, async (elem, index, array) => {
const output: Output = await closure(elem, index, array);
ret.push(output);
});
return ret;
}
export const asyncMap =
<Input>(elements: readonly Input[]) =>
async <Output>(
closure: (
elem: Input,
index: number,
array: readonly Input[],
) => Promise<Output>,
): Promise<Output[]> => {
const ret: Output[] = [];
await asyncForEach(elements)(async (elem, index, array) => {
const output: Output = await closure(elem, index, array);
ret.push(output);
});
return ret;
};
export async function asyncRepeat<T>(
count: number,
closure: (index: number) => Promise<T>,
): Promise<T[]> {
const indexes: number[] = new Array(count)
.fill(1)
.map((_, index) => index);
export const asyncRepeat =
(count: number) =>
async <T>(closure: (index: number) => Promise<T>): Promise<T[]> => {
const indexes: number[] = new Array(count)
.fill(1)
.map((_, index) => index);
const output: T[] = [];
for (const index of indexes) output.push(await closure(index));
const output: T[] = [];
for (const index of indexes) output.push(await closure(index));
return output;
}
return output;
};
export function has<T>(
elements: readonly T[],
pred: (elem: T) => boolean,
): boolean {
return elements.find(pred) !== undefined;
}
export const has =
<T>(elements: readonly T[]) =>
(pred: (elem: T) => boolean): boolean =>
elements.find(pred) !== undefined;
export function repeat<T>(
count: number,
closure: (index: number) => T,
): T[] {
return new Array(count).fill("").map((_, index) => closure(index));
}
export const repeat =
(count: number) =>
<T>(closure: (index: number) => T): T[] =>
new Array(count).fill("").map((_, index) => closure(index));
export function last<T>(array: T[]): T {
return array[array.length - 1];
}
export const flat = <T>(matrix: T[][]): T[] =>
([] as T[]).concat(...matrix);
export function flat<T>(matrix: T[][]): T[] {
return ([] as T[]).concat(...matrix);
}
export function subsets<T>(array: T[]): T[][] {
export const subsets = <T>(array: T[]): T[][] => {
const check: boolean[] = new Array(array.length).fill(false);
const output: T[][] = [];
const dfs = (depth: number) => {
const dfs = (depth: number): void => {
if (depth === check.length)

@@ -98,3 +91,3 @@ output.push(array.filter((_v, idx) => check[idx]));

dfs(depth + 1);
check[depth] = false;

@@ -106,3 +99,3 @@ dfs(depth + 1);

return output;
}
};
}

@@ -22,8 +22,7 @@ import { back_inserter, randint } from "tstl";

*/
export function alphabets(length: number): string {
return new Array(length)
export const alphabets = (length: number): string =>
new Array(length)
.fill("")
.map(() => CHARACTERS[randint(0, CHARACTERS.length - 1)])
.join("");
}

@@ -38,8 +37,7 @@ /**

*/
export function alphaNumeric(length: number): string {
return new Array(length)
export const alphaNumeric = (length: number): string =>
new Array(length)
.fill("")
.map(() => LETTERS[randint(0, LETTERS.length - 1)])
.join("");
}

@@ -52,5 +50,4 @@ /**

*/
export function name(length: number = randint(2, 3)): string {
return paragraph(length)();
}
export const name = (length: number = randint(2, 3)): string =>
paragraph(length)();

@@ -112,3 +109,3 @@ /**

*/
export function substring(content: string): string {
export const substring = (content: string): string => {
const first: number = randint(0, content.length - 1);

@@ -118,3 +115,3 @@ const last: number = randint(first + 1, content.length);

return content.substring(first, last).trim();
}
};

@@ -126,26 +123,15 @@ /**

* @returns Random mobile number
* @example 010-334-0067
*/
export function mobile(prefix: string = "010"): string {
return `${prefix}${digit(3, 4)}${digit(4, 4)}`;
}
export const mobile = (prefix: string = "010"): string =>
[
prefix,
(() => {
const value = randint(0, 9999);
return value.toString().padStart(value < 1_000 ? 3 : 4, "0");
})(),
randint(0, 9999).toString().padStart(4, "0"),
].join("-");
/**
* Generate random digit.
*
* Generate random digit that filling front with zero characters
* when value is less than maximum cipher.
*
* @param minC Minimum cipher
* @param maxC Maximum cipher
* @returns
*/
export function digit(minC: number, maxC: number): string {
const val: number = randint(0, Math.pow(10.0, maxC) - 1);
const log10: number = val ? Math.floor(Math.log10(val)) + 1 : 0;
const prefix: string = "0".repeat(Math.max(0, minC - log10));
return prefix + val.toString();
}
/**
* Generate random date.

@@ -157,6 +143,6 @@ *

*/
export function date(from: Date, range: number): Date {
const time: number = from.getTime() + randint(0, range);
return new Date(time);
}
export const date =
(from: Date) =>
(range: number): Date =>
new Date(from.getTime() + randint(0, range));

@@ -170,7 +156,9 @@ /**

*/
export function sample<T>(array: T[], count: number): T[] {
const ret: T[] = [];
_Sample(array, back_inserter(ret), count);
return ret;
}
export const sample =
<T>(array: T[]) =>
(count: number): T[] => {
const ret: T[] = [];
_Sample(array, back_inserter(ret), count);
return ret;
};

@@ -183,5 +171,4 @@ /**

*/
export function pick<T>(array: T[]): T {
return array[randint(0, array.length - 1)];
}
export const pick = <T>(array: T[]): T =>
array[randint(0, array.length - 1)];
}

@@ -17,7 +17,7 @@ /**

*/
export async function measure(task: Task): Promise<number> {
export const measure = async (task: Task): Promise<number> => {
const time: number = Date.now();
await task();
return Date.now() - time;
}
};

@@ -30,9 +30,11 @@ /**

*/
export async function trace(title: string, task: Task): Promise<number> {
process.stdout.write(` - ${title}: `);
const time: number = await measure(task);
export const trace =
(title: string) =>
async (task: Task): Promise<number> => {
process.stdout.write(` - ${title}: `);
const time: number = await measure(task);
console.log(`${time.toLocaleString()} ms`);
return time;
}
console.log(`${time.toLocaleString()} ms`);
return time;
};
}

@@ -172,6 +172,4 @@ import { is_sorted } from "tstl/ranges";

): Promise<void> => {
const samples: Entity[] = RandomGenerator.sample(
total,
sampleCount,
);
const samples: Entity[] =
RandomGenerator.sample(total)(sampleCount);
for (const s of samples) {

@@ -178,0 +176,0 @@ const values: Values = props.values(s);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc