### Scrambling Numeric Input with Copycat Source: https://github.com/supabase-community/copycat/blob/main/README.md This example demonstrates `copycat.scramble` applied to a number, where each digit is replaced while preserving the floating point. ```js copycat.scramble(782364.902374)\n// => 239724.505138 ``` -------------------------------- ### Mapping First Name PII with Copycat Source: https://github.com/supabase-community/copycat/blob/main/README.md This example demonstrates how Copycat's `firstName` method consistently maps a specific input name ('Susan') to a specific output name ('Therese'), setting up the scenario for a guessing attack. ```js copycat.firstName('Susan') // -> 'Therese' ``` -------------------------------- ### Scrambling Date Objects with Copycat Source: https://github.com/supabase-community/copycat/blob/main/README.md This example shows `copycat.scramble` applied to a Date object, where each segment of the date is scrambled. The output `=> {}` indicates the result of scrambling a Date object. ```js copycat.scramble(new Date('2022-10-25T19:08:39.374Z'))\n// => {} ``` -------------------------------- ### Generate Fictitious Words with copycat.word Source: https://github.com/supabase-community/copycat/blob/main/README.md Documents the `copycat.word` function, which takes an input seed and returns a string resembling a fictitious word. It also details the `options` for controlling capitalization and syllable count, providing JavaScript examples for basic and option-based usage. ```APIDOC copycat.word(input): input: The seed input value. returns: A string value resembling a fictitious word. options: capitalize (boolean): Whether or not the word should start with an upper case letter. Defaults to true. minSyllables (number): The minimum possible number of syllables that returned words will contain. Defaults to 1. maxSyllables (number): The maximum possible number of syllables that returned words will contain. Defaults to 4. ``` ```js copycat.word('foo') // => 'Explicet' ``` ```js copycat.word('id-2', { minSyllables: 3, maxSyllables: 6, unicode: 0.382 }) // => 'Nullam' ``` -------------------------------- ### Generate Password-like Strings with copycat.password Source: https://github.com/supabase-community/copycat/blob/main/README.md Documents the `copycat.password` function, which takes an input seed and returns a string resembling a password. It includes a JavaScript example and notes that it's not recommended for personal password generation due to its deterministic nature. ```APIDOC copycat.password(input): input: The seed input value. returns: A string value resembling a password. Note: Not recommended for use as a personal password generator. ``` ```js copycat.password('foo') // => 'o%qesg^]^x6L' ``` -------------------------------- ### Generate Fictitious Sentences with copycat.sentence Source: https://github.com/supabase-community/copycat/blob/main/README.md Documents the `copycat.sentence` function, which takes an input seed and returns a string resembling a fictitious sentence. It also details the `options` for controlling the number of clauses, words per clause, and syllables per word, with a JavaScript example. ```APIDOC copycat.sentence(input): input: The seed input value. returns: A string value resembling a sentence of fictitious words. options: minClauses (number): The minimum possible number of clauses that a returned sentence will contain. Defaults to 1. maxClauses (number): The maximum possible number of clauses that a returned sentence will contain. Defaults to 2. minWords (number): The minimum possible number of words that each clause will contain. Defaults to 5. maxWords (number): The maximum possible number of words that each clause will contain. Defaults to 8. minSyllables (number): The minimum possible number of syllables that returned words will contain. Defaults to 1. maxSyllables (number): The maximum possible number of syllables that returned words will contain. Defaults to 4. ``` ```js copycat.sentence('foo') // => ' ``` -------------------------------- ### Generate Fictitious Street Addresses with copycat.streetAddress Source: https://github.com/supabase-community/copycat/blob/main/README.md Documents the `copycat.streetAddress` function, which takes an input seed and returns a string representing a fictitious street address. A JavaScript example demonstrates its usage. ```APIDOC copycat.streetAddress(input): input: The seed input value. returns: A string value representing a fictitious street address. ``` ```js copycat.streetAddress('foo') // => '11 Maximilian Isle' ``` -------------------------------- ### Generate Fictitious Timezones with copycat.timezone Source: https://github.com/supabase-community/copycat/blob/main/README.md Documents the `copycat.timezone` function, which takes an input seed and returns a string representing a fictitious timezone. A JavaScript example demonstrates its usage. ```APIDOC copycat.timezone(input): input: The seed input value. returns: A string value representing a time zone. ``` ```js copycat.timezone('foo') // => 'America/Caracas' ``` -------------------------------- ### Generate Fictitious City Names with copycat.city Source: https://github.com/supabase-community/copycat/blob/main/README.md Documents the `copycat.city` function, which takes an input seed and returns a string representing a fictitious city name. A JavaScript example demonstrates its usage. ```APIDOC copycat.city(input): input: The seed input value. returns: A string value representing a city. ``` ```js copycat.city('foo') // => 'Rockford' ``` -------------------------------- ### Generate Fictitious Street Names with copycat.streetName Source: https://github.com/supabase-community/copycat/blob/main/README.md Documents the `copycat.streetName` function, which takes an input seed and returns a string representing a fictitious street name. A JavaScript example demonstrates its usage. ```APIDOC copycat.streetName(input): input: The seed input value. returns: A string value representing a fictitious street name. ``` ```js copycat.streetName('foo') // => 'Jewel Forge' ``` -------------------------------- ### Generate Fictitious Multiple Words with copycat.words Source: https://github.com/supabase-community/copycat/blob/main/README.md Documents the `copycat.words` function, which takes an input seed and returns a string resembling multiple fictitious words. It also details the `options` for controlling the number of words, capitalization, and syllable count, with a JavaScript example. ```APIDOC copycat.words(input): input: The seed input value. returns: A string value resembling fictitious words. options: min (number): The minimum possible number of words that returned strings will contain. Defaults to 2. max (number): The maximum possible number of words that returned strings will contain. Defaults to 3. capitalize (boolean|string): Whether or not the words should start with upper case letters. If true or 'all' is given, each string returned will start with an upper case letter in each word. If 'first' is given, for each string returned, only the first word will start with an upper case letter. If false is given, each string returned will always contain only lower case letters. minSyllables (number): The minimum possible number of syllables that returned words will contain. Defaults to 1. maxSyllables (number): The maximum possible number of syllables that returned words will contain. Defaults to 4. ``` ```js copycat.words('foo') // => 'Aequo ophortatis' ``` -------------------------------- ### Generate Fictitious Country Names with copycat.country Source: https://github.com/supabase-community/copycat/blob/main/README.md Documents the `copycat.country` function, which takes an input seed and returns a string representing a fictitious country name. A JavaScript example demonstrates its usage. ```APIDOC copycat.country(input): input: The seed input value. returns: A string value representing a country. ``` ```js copycat.country('foo') // => 'Tajikistan' ``` -------------------------------- ### Generate Fictitious Postal Addresses with copycat.postalAddress Source: https://github.com/supabase-community/copycat/blob/main/README.md Documents the `copycat.postalAddress` function, which takes an input seed and returns a string representing a fictitious postal address. A JavaScript example demonstrates its usage. ```APIDOC copycat.postalAddress(input): input: The seed input value. returns: A string value representing a fictitious postal address. ``` ```js copycat.postalAddress('foo') // => '114 Pfeffer Bypass, Newport News 1276, Armenia' ``` -------------------------------- ### Generate Fictitious Country Codes with copycat.countryCode Source: https://github.com/supabase-community/copycat/blob/main/README.md Documents the `copycat.countryCode` function, which takes an input seed and returns a string representing a fictitious country code. A JavaScript example demonstrates its usage. ```APIDOC copycat.countryCode(input): input: The seed input value. returns: A string value representing a country code. ``` ```js copycat.countryCode('foo') // => 'GB' ``` -------------------------------- ### Generate One String from Array with Length Limit in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Demonstrates how to use `copycat.oneOfString` to pick a single string from an array, constrained by a character `limit`. If no string matches the limit, a fallback mechanism (not shown in this specific example) would be used. ```js copycat.oneOfString('foo', ['short', 'loooooooong'], { limit: 2 }) // => 'ta' ``` -------------------------------- ### API Reference: copycat.username Options Source: https://github.com/supabase-community/copycat/blob/main/README.md Detailed API documentation for the `options` parameter available with the `copycat.username` function, specifically the `limit` property for constraining output length. ```APIDOC copycat.username options: limit: number description: Constrain generated values to be less than or equal to 'limit' number of characters. ``` -------------------------------- ### API Reference: copycat.unique Parameters and Options Source: https://github.com/supabase-community/copycat/blob/main/README.md Detailed API documentation for the `copycat.unique` function, outlining its required parameters (`input`, `method`, `store`) and optional configuration `options` like `attempts` and `attemptsReached`. ```APIDOC copycat.unique parameters: input: Input description: The seed input for the generation method. method: Function description: A deterministic function that takes 'input' and returns a value of type 'T'. store: Store description: A store object to track generated values and ensure uniqueness. It must have 'has(value: T): boolean' and 'add(value: T): void' methods. options: UniqueOptions description: An optional configuration object for additional control. copycat.unique options: attempts: number description: The maximum number of attempts to generate a unique value. default: 10 attemptsReached: Function description: An optional callback function that is called when the maximum number of attempts is reached. ``` -------------------------------- ### API Options for `copycat.int` Source: https://github.com/supabase-community/copycat/blob/main/README.md Defines the configurable options for the `copycat.int` method. The `min` and `max` options allow specifying the inclusive range for the generated integer. ```APIDOC options: min=0 and max=Infinity: the minimum and maximum possible values for returned numbers ``` -------------------------------- ### Securing Copycat PII Hashing with a Custom Key Source: https://github.com/supabase-community/copycat/blob/main/README.md This code demonstrates how to generate and set a hash key for Copycat. By using a secret key, the mapping of inputs to outputs becomes unpredictable to attackers without the key, effectively preventing guessing attacks. ```js // store this somewhere safe\nconst key = copycat.generateHashKey('g9u*rT#!72R$zl5e')\n\n\ncopycat.fullName('foo')\n// => 'Mohamed Weissnat'\n\ncopycat.setHashKey(key)\n\ncopycat.fullName('foo')\n// => 'Bertha Sauer' ``` -------------------------------- ### API Reference: copycat.phoneNumber Options Source: https://github.com/supabase-community/copycat/blob/main/README.md Detailed API documentation for the `options` parameter available with the `copycat.phoneNumber` function, including `length` and `prefixes` to customize phone number generation. ```APIDOC copycat.phoneNumber options: length: { min: number, max: number } | number description: Constrain generated values to the given length. details: If 'length' is a number, generated values will have exactly this length. If an object '{ min: number, max: number }', values will have a length between 'min' and 'max' (inclusive). prefixes: string[] description: An array of strings to be used as prefixes for the generated phone numbers, allowing control over the country dialing code. ``` -------------------------------- ### API Options for `copycat.url` Source: https://github.com/supabase-community/copycat/blob/main/README.md Defines the configurable options for the `copycat.url` method. The `limit` option constrains the total character length of the generated URL. ```APIDOC options: limit: Constrain generated values to be less than or equal to limit number of chars ``` -------------------------------- ### Demonstrating PII Inference Difficulty with Copycat Source: https://github.com/supabase-community/copycat/blob/main/README.md This snippet shows how Copycat's `fullName` method transforms a sensitive input into an output that is computationally infeasible to reverse engineer, illustrating the difficulty of inferring the original PII. ```js // It is difficult to infer 'Some sensitive input' from 'Rhianna Ebert'\ncopycat.fullName('Some sensitive input')\n// -> 'Rhianna Ebert' ``` -------------------------------- ### API Options for `copycat.firstName` Source: https://github.com/supabase-community/copycat/blob/main/README.md Defines the configurable options for the `copycat.firstName` method. The `limit` option constrains the total character length of the generated first name. ```APIDOC options: limit: Constrain generated values to be less than or equal to limit number of chars ``` -------------------------------- ### API Options for `copycat.oneOfString` Source: https://github.com/supabase-community/copycat/blob/main/README.md Defines the configurable options for the `copycat.oneOfString` method. The `limit` option constrains the length of picked string values, while `fallback` provides a mechanism to handle cases where no values match the specified `limit`. ```APIDOC options: limit: If the values are strings, the picked value will be constrained to be less than or equal limit's amount of characters fallback: string | (input) => string: When limit is specified but no values match the given limit, fallback is called with the given input value. ``` -------------------------------- ### API Options for `copycat.email` Source: https://github.com/supabase-community/copycat/blob/main/README.md Defines the configurable options for the `copycat.email` method. The `limit` option constrains the total character length, and the `domain` option allows specifying a custom domain for the generated email address. ```APIDOC options: limit: Constrain generated values to be less than or equal to limit number of chars domain: Constrain the generated email addresses to use the given domain ``` -------------------------------- ### API Options for `copycat.hex` Source: https://github.com/supabase-community/copycat/blob/main/README.md Defines the configurable options for the `copycat.hex` method. The `min` and `max` options allow specifying the inclusive range for the generated hexadecimal value. ```APIDOC options: min=0 and max=Infinity: the minimum and maximum possible values for returned numbers ``` -------------------------------- ### API Options for `copycat.dateString` Source: https://github.com/supabase-community/copycat/blob/main/README.md Defines the configurable options for the `copycat.dateString` method. Options include `minYear` and `maxYear` for year range, or `min` and `max` for precise date boundaries using `Date` objects or strings. ```APIDOC options: minYear=1980 and maxYear=2019: the minimum and maximum possible year values for returned dates min=new Date(Date.UTC(1980, 0, 1)): Date | string amd max=new Date(Date.UTC(2019, 11, 31, 23, 59, 59, 999)): Date | string: the minimum and maximum possible values. min: Date | string amd max: Date | string: alternatively to minYear and maxYear you can provide exact values. ``` -------------------------------- ### API Reference: copycat.uniqueByInput Function Source: https://github.com/supabase-community/copycat/blob/main/README.md Detailed API documentation for the `copycat.uniqueByInput` function, which generates unique values while preserving consistent outputs for identical inputs. It leverages the `unique` method for new inputs. ```APIDOC copycat.uniqueByInput(input, method, inputStore, resultStore, options): description: Designed to generate unique values while preserving duplicates for identical inputs. purpose: Particularly useful in scenarios where input consistency needs to be maintained alongside the uniqueness of the transformed values. parameters: input: Input description: The seed input for the generation method. method: Function description: A deterministic function that takes 'input' and returns a value of type 'T'. inputStore: Store description: A store object to track input values and their corresponding generated outputs to ensure consistent results for duplicate inputs. resultStore: Store description: A store object to track generated values and ensure uniqueness across different inputs. options: UniqueOptions description: An optional configuration object for additional control, passed to the underlying 'unique' method. behavior: Preserving Input Duplication: If the same input is provided multiple times, 'uniqueByInput' ensures that the transformed value is consistently the same for each occurrence of that input. Uniqueness Preservation: For new and unique inputs, 'uniqueByInput' employs the 'unique' method to generate distinct values, avoiding duplicates in the 'resultStore'. ``` -------------------------------- ### Generate Fictitious MAC Addresses with copycat.mac Source: https://github.com/supabase-community/copycat/blob/main/README.md The `copycat.mac` function takes an input value and returns a string formatted as a fictitious MAC address. ```js copycat.mac('foo') // => '96:d4:46:1a:e9:88' ``` -------------------------------- ### API Options for `copycat.fullName` Source: https://github.com/supabase-community/copycat/blob/main/README.md Defines the configurable options for the `copycat.fullName` method. The `limit` option constrains the total character length of the generated full name. ```APIDOC options: limit: Constrain generated values to be less than or equal to limit number of chars ``` -------------------------------- ### Generate Fictitious User Agent Strings with copycat.userAgent Source: https://github.com/supabase-community/copycat/blob/main/README.md The `copycat.userAgent` function takes an input value and returns a string resembling a browser User Agent string. Currently, it operates from a list of 500 pre-defined user agent strings. ```js copycat.userAgent('foo') // => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.4) Gecko/20100101 Firefox/4284.1468.5020' ``` -------------------------------- ### API Options for `copycat.lastName` Source: https://github.com/supabase-community/copycat/blob/main/README.md Defines the configurable options for the `copycat.lastName` method. The `limit` option constrains the total character length of the generated last name. ```APIDOC options: limit: Constrain generated values to be less than or equal to limit number of chars ``` -------------------------------- ### API: copycat.generateHashKey Source: https://github.com/supabase-community/copycat/blob/main/README.md The `copycat.generateHashKey` function takes a secret value and returns an array containing four 32-bit integer number values. If the secret is shorter or longer than 16 bytes, a seeding key will be derived from it. ```js copycat.generateHashKey('Lhz1Xe7l$vPIwWr3') // => Uint32Array(4) [ 830105676, 1815569752, 1230009892, 863131511 ] ``` -------------------------------- ### Copycat API Reference: Input Parameter Source: https://github.com/supabase-community/copycat/blob/main/README.md Details the universal `input` parameter accepted by all Copycat functions. This parameter can be any JSON-serializable value, and its deterministic serialization ensures consistent output. Object property ordering is not considered for serialization. ```APIDOC Copycat Functions: Parameter: input Type: JSON-serializable value Description: The first parameter for all Copycat functions. For any two calls to the same function, if the input serializes down to the same value, the same output will be returned. Note that unlike JSON.stringify(), object property ordering is not considered. Example Usage: copycat.email(input: string) Description: Generates a deterministic email address. Parameters: input: The string value to base the email generation on. Returns: string JavaScript Example: import { copycat } from '@snaplet/copycat' copycat.email('foo') // => 'Raleigh.McGlynn56687@wholewick.info' ``` -------------------------------- ### Generate Unique Values with copycat.uniqueByInput in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Demonstrates how to use `copycat.uniqueByInput` to generate unique numbers based on a seed, utilizing `Set` objects for `inputStore` and `resultStore` to manage uniqueness and consistency. The `method` function defines the generation logic for the values. ```js // Define a method to generate a value const method = (seed) => { return copycat.int(seed, { max: 3 }); }; // Create stores to track unique values and inputs const resultStore = new Set(); const inputStore = new Set(); // Generate a unique number or retrieve the existing one for duplicate input copycat.uniqueByInput('exampleSeed', method, inputStore, resultStore); // => 3 copycat.uniqueByInput('exampleSeed1', method, inputStore, resultStore); // => 1 copycat.uniqueByInput('exampleSeed', method, inputStore, resultStore); // => 3 ``` -------------------------------- ### copycat.uniqueByInput API Parameters and Options Source: https://github.com/supabase-community/copycat/blob/main/README.md Defines the parameters and optional configuration for the `copycat.uniqueByInput` method, which generates unique values based on input while tracking inputs and results. This method ensures consistent output for duplicate inputs and uniqueness for generated values. ```APIDOC parameters: input (Input): The seed input for the generation method. method (Function): A deterministic function that takes input and returns a value of type T. inputStore (Store): A store object to track the inputs and ensure consistent output for duplicate inputs. resultStore (Store): A store object to track the generated values and ensure their uniqueness. options (UniqueOptions): An optional configuration object for additional control. options: attempts (number): The maximum number of attempts to generate a unique value after transformation. Defaults to 10. attemptsReached (Function): An optional callback function that is invoked when the maximum number of attempts is reached. ``` -------------------------------- ### Generate Email Address with Custom Domain in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Demonstrates using `copycat.email` with the `domain` option to generate an email address that uses a specific domain, ensuring consistency for testing or mock data generation. ```js copycat.email('foo', { domain: 'acme.org' }) // => 'Albin_Goyette47922@acme.org' ``` -------------------------------- ### `copycat.scramble` Method Source: https://github.com/supabase-community/copycat/blob/main/README.md This method takes an `input` value and returns a value of the same type and length, with characters/digits replaced. It details how different types (string, number, object/array, date, boolean/null) are handled, and lists the `preserve` option. ```APIDOC copycat.scramble(input[, options]):\n Description: Takes an `input` value and returns a value of the same type and length, but with each character/digit replaced.\n Parameters:\n input: The value to scramble.\n options (optional): An object containing options for scrambling.\n Options:\n preserve: An array of characters that should remain the same if present in the given input string.\n Behavior:\n String: Replacement characters in the same character range. Spaces preserved by default. Lower/upper ASCII replaced with same case ASCII letters. Digits replaced with digits. Other ASCII (0x20-0x7e) replaced with alphanumeric or '_', '-', '+'. Other characters replaced with Latin-1 (0x20-0x7e, 0xa0-0xff).\n Number: Each digit replaced, floating point preserved.\n Object/Array: Values inside recursively scrambled.\n Date: Each segment in the date scrambled.\n Boolean/Null: Value returned as is.\n Other types: Throws an error. ``` -------------------------------- ### Scrambling String Input with Copycat Source: https://github.com/supabase-community/copycat/blob/main/README.md This snippet shows `copycat.scramble` transforming a string input by replacing each character with a different one from the same character range, while preserving spaces by default. ```js copycat.scramble('Zakary Hessel')\n// => 'Vqjmtp Rkbqyl' ``` -------------------------------- ### `copycat.oneOf` Method Source: https://github.com/supabase-community/copycat/blob/main/README.md This method takes an `input` value and an array of `values`, returning an item from `values` that corresponds to the `input`. ```APIDOC copycat.oneOf(input, values[, options]):\n Description: Takes an `input` value and an array of `values`, and returns an item in `values` that corresponds to that `input`.\n Parameters:\n input: The input value used for selection.\n values: An array of values to choose from.\n options (optional): Additional options. ``` -------------------------------- ### Generate Fictitious IPv4 Addresses with copycat.ipv4 Source: https://github.com/supabase-community/copycat/blob/main/README.md The `copycat.ipv4` function takes an input value and returns a string formatted as a fictitious IPv4 address. ```js copycat.ipv4('foo') // => '215.127.85.213' ``` -------------------------------- ### Simulating a Guessing Attack to Infer Original PII Source: https://github.com/supabase-community/copycat/blob/main/README.md This snippet illustrates a potential guessing attack where an attacker can iterate through common first names to find an input that maps to a known output, thereby inferring the original sensitive data. ```js copycat.firstName('John') // -> 'April', no match\ncopycat.firstName('Sarah') // -> 'Florencio', no match\ncopycat.firstName('Susan') // -> 'Therese', match! ``` -------------------------------- ### `fictional` Module Re-export Source: https://github.com/supabase-community/copycat/blob/main/README.md This section documents the `fictional` module, which is a re-export of the `fictional` library. It is used internally by Copycat for mapping inputs to primitive values. ```APIDOC fictional:\n Description: A re-export of `fictional` from `https://github.com/oftherivier/fictional`.\n Usage: Used under the hood by copycat for mapping inputs to primitive values. ``` -------------------------------- ### Generate Fictitious Paragraphs with copycat.paragraph Source: https://github.com/supabase-community/copycat/blob/main/README.md The `copycat.paragraph` function takes an input value and returns a string resembling a paragraph of fictitious words. It supports various options to control the generated paragraph's structure, including `minSentences` (default 3) and `maxSentences` (default 7) for the number of sentences, `minClauses` (default 1) and `maxClauses` (default 2) per sentence, `minWords` (default 5) and `maxWords` (default 8) per clause, and `minSyllables` (default 1) and `maxSyllables` (default 4) per word. ```js copycat.paragraph('foo') // => 'Et modo lucilias legatomnem et. Quis ratio iudicur ut defuitur quod interessar endis, doloria romandum athenisse explicem quia. Expeten quam hoc ex amus ant sive, providintem ad claudicur torquato nes nihil nec ut. Audiri dicerea summum arisset ne exceperem tam si, amartifex doloris nam quae ipsum. Et causa iudicitat extremum endam tota tum antippus, de vidi videbo rerum ut. Affere ab mundi nimium summa partemerror causae, his am semperfruique in sapiens gloriatur et dicenim.' ``` -------------------------------- ### Set Internal Hash Key with copycat.setHashKey Source: https://github.com/supabase-community/copycat/blob/main/README.md The `copycat.setHashKey` function updates copycat's internal state to use a specified key for mapping inputs to output values. The `key` can be a string, from which four 32-bit integers will be derived, or an array of four 32-bit integers as returned by `copycat.generateHashKey()`. ```js const key = copycat.generateHashKey('Lhz1Xe7l$vPIwWr3') copycat.setHashKey(key) ``` -------------------------------- ### `copycat.oneOfString` Method Source: https://github.com/supabase-community/copycat/blob/main/README.md Similar to `oneOf()`, but `values` must be an array of string values, and only values within the character limit set by the `limit` option will be picked. ```APIDOC copycat.oneOfString(input, values[, options]):\n Description: Like `oneOf()`, takes an `input` value and an array of `values`, and returns an item in `values` that corresponds to that `input`. `values` must be an array of _string_ values, and only values within the character limit set by the `limit` option will be picked.\n Parameters:\n input: The input value used for selection.\n values: An array of string values to choose from.\n options (optional): Additional options.\n limit: The maximum character length for picked string values. ``` -------------------------------- ### Generate Usernames with Copycat Source: https://github.com/supabase-community/copycat/blob/main/README.md The `copycat.username` function generates a string resembling a username from a given input seed. It can be constrained by an optional `limit` on the number of characters. ```js copycat.username('foo') // => 'Albin.Goyette47922' ``` -------------------------------- ### Generate Integer Number in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Shows how to use `copycat.int` to generate a pseudo-random integer based on an input value. This method can be configured with `min` and `max` options to constrain the output range. ```js copycat.int('foo') // => 5208378699696662 ``` -------------------------------- ### Generate First Name String in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Shows how `copycat.firstName` generates a string resembling a first name based on an input value. It supports a `limit` option to constrain the total length of the generated name. ```js copycat.firstName('foo') // => 'Morris' ``` -------------------------------- ### Generate URL String in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Illustrates `copycat.url`, a method for generating a string resembling a URL based on an input value. It supports a `limit` option to constrain the total length of the generated URL. ```js copycat.url('foo') // => 'https://noisy-shoe.biz' ``` -------------------------------- ### Generate Deterministic Email Addresses (JavaScript) Source: https://github.com/supabase-community/copycat/blob/main/README.md Illustrates the core functionality of Copycat using `copycat.email`. For a given input string, the function consistently produces the same anonymized email address, highlighting Copycat's deterministic mapping feature. This ensures data consistency across multiple operations. ```js import { copycat } from '@snaplet/copycat' copycat.email('foo') // => 'Raleigh.McGlynn56687@wholewick.info' copycat.email('bar') // => 'Amir_Kris69246@raw-lout.name' copycat.email('foo') // => 'Raleigh.McGlynn56687@wholewick.info' ``` -------------------------------- ### Generate Email Address String in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Shows how `copycat.email` generates a string resembling an email address based on an input value. It supports options to constrain the total length or specify a custom domain for the generated email. ```js copycat.email('foo') // => 'Albin_Goyette47922@drum-margin.name' ``` -------------------------------- ### Selecting One Value from an Array Based on Input Source: https://github.com/supabase-community/copycat/blob/main/README.md This snippet illustrates `copycat.oneOf`, which takes an input value and an array of possible values, returning one item from the array that consistently corresponds to the given input. ```js copycat.oneOf('foo', ['red', 'green', 'blue'])\n// => 'green' ``` -------------------------------- ### Generate Floating-Point Number in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Illustrates `copycat.float`, a method for generating a pseudo-random floating-point number. It can be configured with `min` and `max` options to define the desired range for the generated value. ```js copycat.float('foo', { min: 0, max: 1 }) // => 0.5782461953370469 ``` -------------------------------- ### JSON Structure for Method Performance Metrics Source: https://github.com/supabase-community/copycat/blob/main/records/benchmarks/0.8.0--improve-collisions-email--collisions.txt This snippet demonstrates the JSON format used to record performance statistics for individual methods. It includes fields such as the method name, statistical aggregates (mean, standard deviation, margin of error), execution details (number of runs, minimum, maximum, sum), collision status, and total duration. ```JSON {"methodName":"username","mean":"800847.73","stddev":"138023.51","moe":"0.10","runs":50,"n":11,"min":485308,"max":994067,"sum":999999,"hasCollided":true,"duration":7921728} ``` ```JSON {"methodName":"email","mean":null,"stddev":null,"moe":null,"runs":50,"n":0,"min":null,"max":null,"sum":999999,"hasCollided":false,"duration":19710157} ``` -------------------------------- ### Selecting String from Array with Character Limit Source: https://github.com/supabase-community/copycat/blob/main/README.md This snippet demonstrates `copycat.oneOfString`, which is similar to `oneOf` but specifically for string arrays, and allows filtering results based on a `limit` option for character length. ```js copycat.oneOfString('foo', ['short', 'loooooooong'], { limit: 6 })\n// => 'short' ``` -------------------------------- ### Generate Boolean Value in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Demonstrates `copycat.bool`, which generates a pseudo-random boolean value based on a provided input. This is useful for creating consistent boolean outputs for a given seed. ```js copycat.bool('foo') // => false ``` -------------------------------- ### Generate Last Name String in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Illustrates `copycat.lastName`, a method for generating a string resembling a last name based on an input value. It supports a `limit` option to constrain the total length of the generated name. ```js copycat.lastName('foo') // => 'Gleichner' ``` -------------------------------- ### Call Function Multiple Times with copycat.times Source: https://github.com/supabase-community/copycat/blob/main/README.md The `copycat.times` function repeatedly calls a provided function `fn` for a specified number of times, each with a unique input derived from the initial `input` value. It returns the results as an array. The `range` parameter can be a tuple array `[min, max]` to specify a range of calls, or a single number for an exact count. ```js copycat.times('foo', [4, 5], copycat.word) // => [ 'Conspecta', 'Mihi', 'Fuisse', 'Philos', 'Divelistius' ] ``` ```js copycat.times('foo', 2, copycat.word) // => [ 'Pugnari', 'Conspecta' ] ``` -------------------------------- ### Preserving Specific Characters During String Scrambling Source: https://github.com/supabase-community/copycat/blob/main/README.md This snippet demonstrates using the `preserve` option with `copycat.scramble` to ensure that specified characters (like '@' and '.') remain unchanged in the scrambled output string. ```js copycat.scramble('foo@bar.org', { preserve: ['@', '.'] })\n// => 'nzx@vib.elt' ``` -------------------------------- ### `faker` Module Re-export Source: https://github.com/supabase-community/copycat/blob/main/README.md This section documents the `faker` module, which is a re-export of `@faker-js/faker`. It notes that Copycat does not alter or seed `faker`. ```APIDOC faker:\n Description: A re-export of `faker` from `@faker-js/faker`.\n Notes: Not altered or seeded by Copycat. ``` -------------------------------- ### Generate Full Name String in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Shows how `copycat.fullName` generates a string resembling a full name (first and last name combined) based on an input value. It supports a `limit` option to constrain the total length of the generated name. ```js copycat.fullName('foo') // => 'Bertha Sauer' ``` -------------------------------- ### Generate ISO 8601 Date String in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Shows how `copycat.dateString` generates a date string in ISO 8601 format based on an input value. This method supports options for constraining the year range or providing exact date boundaries. ```js copycat.dateString('foo') // => '2002-03-15T14:10:10.000Z' ``` -------------------------------- ### Generate Single Hexadecimal Character in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Illustrates `copycat.hex`, a method for generating a single hexadecimal character based on an input value. This is useful for creating hex-formatted string outputs. ```js copycat.hex('foo') // => '6' ``` -------------------------------- ### Generate Unique Values with Copycat Source: https://github.com/supabase-community/copycat/blob/main/README.md The `copycat.unique` function ensures that transformed values remain unique, even if input values are identical. It attempts to generate a new value multiple times until a unique one is found, storing generated values in a provided `store` object. Note that this method is not stateless and its determinism depends on the input, store state, and attempts. ```js const generateValue = (seed) => { return copycat.int(seed, { max: 3 }); }; const store = new Set(); copycat.unique('exampleSeed', generateValue, store); // => 3 copycat.unique('exampleSeed1', generateValue, store); // => 1 copycat.unique('exampleSeed', generateValue, store); // => 0 ``` -------------------------------- ### Generate Phone Numbers with Copycat Source: https://github.com/supabase-community/copycat/blob/main/README.md The `copycat.phoneNumber` function generates a string resembling a phone number based on an input seed. It supports optional parameters to control the length and prefixes of the generated number, though it does not guarantee validity. ```js copycat.phoneNumber('foo') // => '+208438699696662' ``` ```js copycat.phoneNumber('foo', { prefixes: ['+3319900', '+3363998'], length: 11 }) // => '+3363998462' ``` -------------------------------- ### Generate UUID String in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Illustrates `copycat.uuid`, a method for generating a string resembling a Universally Unique Identifier (UUID) based on an input value. This ensures consistent UUID generation for a given seed. ```js copycat.uuid('foo') // => '2fabe7f3-6216-5e0b-a885-4fb9951363f5' ``` -------------------------------- ### Generate Multiple Strings from Array in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Illustrates the `copycat.someOf` method, which selects a specified number of unique items from an array based on an input value and a given range. Each item will be picked no more than once. ```js copycat.someOf('foo', [1,2], ['paper', 'rock']) // => [ 'rock' ] ``` -------------------------------- ### Recursively Scrambling Object and Array Structures Source: https://github.com/supabase-community/copycat/blob/main/README.md This snippet illustrates `copycat.scramble`'s ability to recursively process and scramble values within nested objects and arrays, maintaining the original structure. ```js copycat.scramble({\n a: [\n {\n b: 23,\n c: 'foo'\n }\n ]\n})\n// => { a: [ { b: 10, c: 'mem' } ] } ``` -------------------------------- ### Generate Single Digit Character in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Demonstrates `copycat.digit`, which generates a single digit character (0-9) based on an input value. This method is useful for creating numeric string outputs. ```js copycat.digit('foo') // => '2' ``` -------------------------------- ### Generate Single Alphanumeric Character in JavaScript Source: https://github.com/supabase-community/copycat/blob/main/README.md Shows how `copycat.char` generates a single alphanumeric character (lowercase/uppercase ASCII letters or digits 0-9) based on an input value. This is useful for creating single-character outputs. ```js copycat.char('foo') // => 'a' ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.