Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@snaplet/copycat

Package Overview
Dependencies
Maintainers
4
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@snaplet/copycat - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

129

dist/copycat.limit.test.js

@@ -27,2 +27,3 @@ var __defProp = Object.defineProperty;

"email",
"username",
"firstName",

@@ -51,12 +52,12 @@ "lastName",

"email": Array [
"Bo_King114@gmail.net",
"Bo_Koch349@yahoo.net",
"Bo_Ward471@yahoo.com",
"Bo_Toy949@gmail.com",
"Ed_Dare472@yahoo.com",
"Bo_Wiza59@yahoo.info",
"Bo_Toy189@gmail.info",
"Bo_Von60@gmail.biz",
"Ed_Kub941@gmail.org",
"Ed_Cole773@yahoo.net",
"M_Yu55370@fgene.biz",
"V.Vi21967@q-rap.info",
"V_Ra85431@S-guy.org",
"V.So17165@axhead.org",
"K_Yu46526@cccake.org",
"K.Mi84888@h-bee.com",
"K.Ra65715@c-bow.info",
"Y_So44969@R-pun.com",
"Y_Ko37263@V-pop.com",
"V_Yu5335@J-sir.org",
],

@@ -99,2 +100,14 @@ "firstName": Array [

],
"username": Array [
"ugly_clasp55370",
"flat-shift21967",
"good_wit85431",
"mild-derby17165",
"find-mess46526",
"vast_magic84888",
"mad-bootee65715",
"thin_dew44969",
"find.moai37263",
"damn-guava5335",
],
}

@@ -107,12 +120,12 @@ `);

"email": Array [
"VvK1@ko.yu",
"MmK3@mi.ra",
"SsK4@vi.vi",
"KsY9@mi.so",
"MmR4@yu.ko",
"YrK5@yu.vi",
"KkS1@ra.vi",
"MmR6@ko.ra",
"YsM9@yu.yu",
"MyV7@so.yu",
"M55@fA.koy",
"V21@q.net",
"V85@S.net",
"V17@yK.mik",
"K46@PG.yuk",
"K84@h.biz",
"K65@c.biz",
"Y44@R.biz",
"Y37@V.net",
"V53@J.com",
],

@@ -155,2 +168,14 @@ "firstName": Array [

],
"username": Array [
"B55370",
"I21967",
"J85431",
"Y17165",
"b46526",
"r84888",
"f65715",
"b44969",
"T37263",
"C5335",
],
}

@@ -163,12 +188,12 @@ `);

"email": Array [
"Liliane_Powlowski114@gmail.net",
"Emely_Buckridge349@yahoo.net",
"Jeffry_Kshlerin471@yahoo.com",
"Norbert_Funk949@gmail.com",
"Lyda_Schowalter472@yahoo.com",
"Kaylie_Yost59@yahoo.info",
"Catherine_Schmitt189@gmail.info",
"Elinore_Kshlerin60@gmail.biz",
"Jace_Boehm941@gmail.org",
"Howell_Bergnaum773@yahoo.net",
"Ibrahim_Robel55370@flamboyantphenotype.biz",
"Randal.Sipes21967@postpone-bloodflow.info",
"Frank_Hahn85431@coach-competence.org",
"Eugene.Kuvalis17165@joldisguise.org",
"Scarlett_Farrell46526@eddyslapstick.org",
"Lloyd.Koss84888@grateful-adobe.com",
"Alford.Harber65715@dirty-catalyst.info",
"Deven_Jakubowski44969@coat-caution.com",
"Matilda_Buckridge37263@tidy-corn.com",
"Cody_Murazik5335@expensive-wasp.org",
],

@@ -211,2 +236,14 @@ "firstName": Array [

],
"username": Array [
"careless_scrutiny55370",
"cluttered-executor21967",
"grouchy_advantage85431",
"nutty-elevator17165",
"snipe-saffron46526",
"fitting_young84888",
"functional-thistle65715",
"fussy_graphic44969",
"denitrify.conduct37263",
"embitter-shift5335",
],
}

@@ -219,12 +256,12 @@ `);

"email": Array [
"1@k.y",
"3@m.r",
"4@v.v",
"9@m.s",
"4@y.k",
"5@y.v",
"1@r.v",
"6@k.r",
"9@y.y",
"7@s.y",
"M@f.k",
"V@q.m",
"V@S.v",
"V@y.m",
"K@P.y",
"K@h.y",
"K@c.r",
"Y@R.k",
"Y@V.y",
"V@J.s",
],

@@ -267,2 +304,14 @@ "firstName": Array [

],
"username": Array [
"B5537",
"I2196",
"J8543",
"Y1716",
"b4652",
"r8488",
"f6571",
"b4496",
"T3726",
"C5335",
],
}

@@ -269,0 +318,0 @@ `);

@@ -112,12 +112,12 @@ var import_testutils = require("./testutils");

"email": Array [
"Tyson_Will811@gmail.net",
"Hardy.Daniel486@hotmail.info",
"Uriah_Mertz865@yahoo.name",
"Filomena_Leannon845@gmail.net",
"Lurline_Goyette232@hotmail.biz",
"Cathy.McLaughlin406@gmail.net",
"Erna_Lueilwitz257@yahoo.com",
"Lloyd.Block46@hotmail.net",
"Alec_Cummings95@hotmail.com",
"Irma.Hudson664@hotmail.biz",
"Narciso.Dooley34672@openterrorist.name",
"Meda_Keeling5196@writhing-advantage.info",
"Chase.O'Kon80745@pullonline.biz",
"Gilda.Lehner50152@granularcopper.com",
"Josh_Beier4249@prejudice-lute.org",
"Marquis.Schuppe92071@tip-ammunition.com",
"Hulda.Reilly73970@cork-crewmember.net",
"Louvenia_Corwin51813@generous-barbeque.info",
"Aurelio.Ankunding88761@calm-sundial.org",
"Veronica_Romaguera96398@pony-thunderhead.org",
],

@@ -458,12 +458,12 @@ "firstName": Array [

"username": Array [
"Tyson_Will811",
"Hardy.Daniel486",
"Uriah_Mertz865",
"Filomena_Leannon845",
"Lurline_Goyette232",
"Cathy.McLaughlin406",
"Erna_Lueilwitz257",
"Lloyd.Block46",
"Alec_Cummings95",
"Irma.Hudson664",
"inborn-espadrille34672",
"deplane.tree5196",
"Chase_O'Kon80745",
"cash.constitution50152",
"preclude_gymnastics4249",
"Marquis-Schuppe92071",
"Hulda-Reilly73970",
"misname_midden51813",
"masculinize.ingredient88761",
"jog-street96398",
],

@@ -470,0 +470,0 @@ "uuid": Array [

@@ -28,2 +28,3 @@ var __create = Object.create;

var import_fictional = require("fictional");
var import_despace = require("./despace");
var import_firstName = require("./firstName");

@@ -33,12 +34,24 @@ var import_join = require("./join");

var import_oneOfString = require("./oneOfString");
var import_primitives = require("./primitives");
const domainNameSegments = ["", "-"].map((joiner) => [
(0, import_join.join)(joiner, [
(0, import_oneOfString.oneOfString)(import_faker.default.locales.en.word.adjective.map(import_despace.despace), import_primitives.char.letter),
(0, import_oneOfString.oneOfString)(import_faker.default.locales.en.word.noun.map(import_despace.despace), import_primitives.char.letter)
]),
(0, import_join.join)(joiner, [
(0, import_oneOfString.oneOfString)(import_faker.default.locales.en.word.verb.map(import_despace.despace), import_primitives.char.letter),
(0, import_oneOfString.oneOfString)(import_faker.default.locales.en.word.noun.map(import_despace.despace), import_primitives.char.letter)
])
]).flat();
const email = (input, options = {}) => (0, import_join.join)(input, "", [
import_firstName.firstName,
(0, import_oneOfString.oneOfString)(["_", "."]),
import_lastName.lastName,
(0, import_primitives.oneOf)([
(0, import_join.join)("_", [import_firstName.firstName, import_lastName.lastName]),
(0, import_join.join)(".", [import_firstName.firstName, import_lastName.lastName])
]),
import_fictional.int.options({
min: 2,
max: 999
max: 99999
}),
"@",
(0, import_oneOfString.oneOfString)(["gmail", "yahoo", "hotmail"]),
(0, import_primitives.oneOf)(domainNameSegments),
".",

@@ -45,0 +58,0 @@ (0, import_oneOfString.oneOfString)(import_faker.default.locales.en.internet.domain_suffix)

@@ -1,2 +0,2 @@

export declare const firstName: (input: import("fictional").JSONSerializable, options?: import("./oneOfString").OneOfOptions) => string;
export declare const firstName: (input: import("fictional").JSONSerializable, options?: import("./oneOfString").OneOfOptions) => any;
//# sourceMappingURL=firstName.d.ts.map
export { faker } from '@faker-js/faker';
export * as fictional from 'fictional';
export * as copycat from './copycat';
export * from './types';
//# sourceMappingURL=index.d.ts.map

@@ -25,6 +25,8 @@ var __create = Object.create;

copycat: () => copycat,
faker: () => import_faker.faker
faker: () => import_faker.faker,
fictional: () => fictional
});
module.exports = __toCommonJS(src_exports);
var import_faker = require("@faker-js/faker");
var fictional = __toESM(require("fictional"));
var copycat = __toESM(require("./copycat"));

@@ -35,3 +37,4 @@ __reExport(src_exports, require("./types"), module.exports);

copycat,
faker
faker,
fictional
});

@@ -6,4 +6,6 @@ import { Input } from 'fictional';

}
export declare const join: (input: Input, joiner: string, segments: Transform[], options?: JoinOptions) => string;
export declare const join: ((joiner: string, segments: Transform[]) => (input: Input, options?: JoinOptions | undefined) => string) & ((input: Input, joiner: string, segments: Transform[], options?: JoinOptions) => string);
export declare const joinCurried: (joiner: string, segments: Transform[]) => (input: Input, options?: JoinOptions | undefined) => string;
export declare const joinMain: (input: Input, joiner: string, segments: Transform[], options?: JoinOptions) => string;
export {};
//# sourceMappingURL=join.d.ts.map

@@ -20,11 +20,17 @@ var __defProp = Object.defineProperty;

__export(join_exports, {
join: () => join
join: () => join,
joinCurried: () => joinCurried,
joinMain: () => joinMain
});
module.exports = __toCommonJS(join_exports);
var import_fictional = require("fictional");
const join = (input, joiner, segments, options = {}) => {
const { limit } = options;
if (limit == null) {
const joinEntry = (a, b, c, d) => c != null ? joinMain(a, b, c, d) : joinCurried(a, b);
const join = joinEntry;
const joinCurried = (joiner, segments) => (input, options) => joinMain(input, joiner, segments, options);
const joinMain = (input, joiner, segments, options = {}) => {
const { limit: rawLimit } = options;
if (rawLimit == null) {
return (0, import_fictional.join)(input, joiner, segments);
}
const limit = Math.max(1, rawLimit);
let nextInput = (0, import_fictional.hash)([input, "copycat:join"]);

@@ -37,15 +43,18 @@ const segmentBudgetMetadata = computeSegmentBudgetMetadata(segments, joiner, limit);

const resolvedSegments = [];
let i = -1;
for (const segment of segments) {
nextInput = (0, import_fictional.hash)(nextInput);
const [nextSegmentBudgetState, segmentResult] = resolveSegment(nextInput, segmentBudgetState, segmentBudgetMetadata, segment);
const [nextSegmentBudgetState, segmentResult] = resolveSegment(nextInput, segmentBudgetState, segmentBudgetMetadata, segment, ++i);
segmentBudgetState = nextSegmentBudgetState;
resolvedSegments.push(segmentResult);
if (segmentResult) {
resolvedSegments.push(segmentResult);
}
}
return resolvedSegments.join(joiner);
};
const resolveSegment = (input, state, metadata, segment) => {
const resolveSegment = (input, state, metadata, segment, index) => {
if (typeof segment !== "function") {
return [state, segment.toString()];
}
const budget = computeSegmentBudget(state, metadata);
const budget = computeSegmentBudget(state, metadata, index);
const segmentResult = segment(input, { limit: budget }).toString().slice(0, budget);

@@ -76,3 +85,3 @@ const nextState = {

};
const computeSegmentBudget = (state, metadata) => {
const computeSegmentBudget = (state, metadata, index) => {
const { fnSegmentCount, fixedLen, limit } = metadata;

@@ -82,7 +91,9 @@ const { seenFnSegmentCount, takenFnSegmentLen } = state;

const remainingSegmentCount = fnSegmentCount - seenFnSegmentCount;
return Math.max(0, Math.floor(availableLen / remainingSegmentCount));
return Math.max(index === 0 ? 1 : 0, Math.floor(availableLen / remainingSegmentCount));
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
join
join,
joinCurried,
joinMain
});

@@ -1,2 +0,2 @@

export declare const lastName: (input: import("fictional").JSONSerializable, options?: import("./oneOfString").OneOfOptions) => string;
export declare const lastName: (input: import("fictional").JSONSerializable, options?: import("./oneOfString").OneOfOptions) => any;
//# sourceMappingURL=lastName.d.ts.map
import { Input } from 'fictional';
import { Transform } from './types';
export interface OneOfOptions {
limit?: number;
}
export declare const oneOfString: (rawChoices: string[], fallback?: import("fictional").Word) => (input: Input, options?: OneOfOptions) => string;
export declare const oneOfString: (rawChoices: string[], fallback?: string | number | Transform) => (input: Input, options?: OneOfOptions) => any;
//# sourceMappingURL=oneOfString.d.ts.map

@@ -35,3 +35,4 @@ var __defProp = Object.defineProperty;

if (choices.length === 0) {
return fallback([input, "copycat:oneOfString"]).slice(0, limit);
const fallbackResult = typeof fallback !== "function" ? fallback : fallback([input, "copycat:oneOfString"]);
return fallbackResult.toString().slice(0, limit);
}

@@ -38,0 +39,0 @@ return (0, import_fictional.oneOf)(input, choices);

import { Input } from './types';
export declare const username: (input: Input) => string;
interface UsernameOptions {
limit?: number;
}
export declare const username: (input: Input, options?: UsernameOptions) => string;
export {};
//# sourceMappingURL=username.d.ts.map

@@ -0,4 +1,6 @@

var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;

@@ -17,2 +19,3 @@ var __export = (target, all) => {

};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

@@ -24,15 +27,28 @@ var username_exports = {};

module.exports = __toCommonJS(username_exports);
var import_faker = __toESM(require("@faker-js/faker"));
var import_fictional = require("fictional");
var import_despace = require("./despace");
var import_firstName = require("./firstName");
var import_join = require("./join");
var import_lastName = require("./lastName");
const maker = (0, import_fictional.join)("", [
import_firstName.firstName,
(0, import_fictional.oneOf)(["_", "."]),
import_lastName.lastName,
var import_oneOfString = require("./oneOfString");
var import_primitives = require("./primitives");
const nameSegments = ["-", ".", "_"].map((joiner) => [
(0, import_join.join)(joiner, [import_firstName.firstName, import_lastName.lastName]),
(0, import_join.join)(joiner, [
(0, import_oneOfString.oneOfString)(import_faker.default.locales.en.word.adjective.map(import_despace.despace), import_primitives.char.letter),
(0, import_oneOfString.oneOfString)(import_faker.default.locales.en.word.noun.map(import_despace.despace), "")
]),
(0, import_join.join)(joiner, [
(0, import_oneOfString.oneOfString)(import_faker.default.locales.en.word.verb.map(import_despace.despace), import_primitives.char.letter),
(0, import_oneOfString.oneOfString)(import_faker.default.locales.en.word.noun.map(import_despace.despace), "")
])
]).flat();
const username = (input, options = {}) => (0, import_join.join)(input, "", [
(0, import_fictional.oneOf)(nameSegments),
import_fictional.int.options({
min: 2,
max: 999
max: 99999
})
]);
const username = (input) => maker(input);
], options);
// Annotate the CommonJS export names for ESM import in node:

@@ -39,0 +55,0 @@ 0 && (module.exports = {

{
"name": "@snaplet/copycat",
"version": "0.10.0",
"version": "0.11.0",
"description": "",

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

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

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