New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@snaplet/copycat

Package Overview
Dependencies
Maintainers
2
Versions
59
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.3.0 to 0.4.0

dist/scramble.d.ts

2

dist/copycat.d.ts

@@ -20,2 +20,4 @@ export * from './primitives';

export * from './userAgent';
export * from './scramble';
export * from './setSalt';
//# sourceMappingURL=copycat.d.ts.map

@@ -36,1 +36,3 @@ var __defProp = Object.defineProperty;

__reExport(copycat_exports, require("./userAgent"), module.exports);
__reExport(copycat_exports, require("./scramble"), module.exports);
__reExport(copycat_exports, require("./setSalt"), module.exports);

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

var import__ = require(".");
var import_testutils = require("./testutils");

@@ -12,3 +11,3 @@ test("determinism", () => {

};
Object.keys(import__.copycat).forEach(check);
Object.keys(import_testutils.TRANSFORMATIONS).forEach(check);
});

@@ -281,2 +280,14 @@ test("generated values", () => {

],
"scramble": Array [
"Evpitkg Zhans",
"Qqgh Ajmfw",
"Ltquwqj Buirwwg",
"Lsh Jgtnrwe",
"Bic Fkgqzfgsi",
"Hqtqyey Kvvbprgjc",
"Mgwo Ebzx",
"Npyeas Fzgdwx",
"Igc Lrkslv",
"Kratw Trbekhh",
],
"sentence": Array [

@@ -283,0 +294,0 @@ "Vivano mera nanichiha ni moshiyu sochi kinrame kinma.",

3

dist/testutils.d.ts
import { Input } from './types';
import { JSONSerializable } from 'fictional';
export declare const TRANSFORMATIONS: {
[name: string]: (input: Input) => JSONSerializable;
[name: string]: (input: Input) => unknown;
};

@@ -6,0 +5,0 @@ export declare const NUM_CHECKS: number;

@@ -40,5 +40,7 @@ var __defProp = Object.defineProperty;

var import__ = require(".");
const TRANSFORMATIONS = __spreadValues(__spreadValues({}, import__.copycat), {
const EXCLUDED_METHODS = /* @__PURE__ */ new Set(["setSalt"]);
const TRANSFORMATIONS = __spreadValues(__spreadValues({}, Object.fromEntries(Object.keys(import__.copycat).filter((k) => !EXCLUDED_METHODS.has(k)).map((k) => [k, import__.copycat[k]]))), {
times: (input) => import__.copycat.times(input, [4, 5], import__.copycat.word),
oneOf: (input) => import__.copycat.oneOf(input, ["red", "green", "blue"])
oneOf: (input) => import__.copycat.oneOf(input, ["red", "green", "blue"]),
scramble: (input) => import__.copycat.scramble(import__.copycat.fullName(input))
});

@@ -45,0 +47,0 @@ const NUM_CHECKS = +(process.env.COPYCAT_NUM_CHECKS || 50);

{
"name": "@snaplet/copycat",
"version": "0.3.0",
"version": "0.4.0",
"description": "",

@@ -16,3 +16,3 @@ "main": "dist/index.js",

"@faker-js/faker": "^6.2.0",
"fictional": "^0.4.13",
"fictional": "^0.4.15",
"uuid": "^8.3.2"

@@ -19,0 +19,0 @@ },

@@ -76,27 +76,36 @@ # ![copycat](https://user-images.githubusercontent.com/1731223/167850970-584e6953-6543-4085-af5a-f9d8b7ffe988.png)

### `copycat.oneOf(input, values)`
### `copycat.scramble(string[, options])`
Takes in an [`input`](#input) value and an array of `values`, and returns an item in `values` that corresponds to that `input`:
Takes in a `string` value, and returns a string with the same length, but with each character replaced with a different character in the same character range:
* By default, spaces are preserved (see `preserve` option below)
* Lower case ascii characters are replaced with lower case ascii letters
* Upper case ascii characters are replaced with upper case ascii letters
* Digits are replaced with digits
* Any other ascii character in the code point range `32` to `126` (`0x20 - 0x7e`) is replaced with an ascii in the same range
* Any other character is replaced with a [Latin-1](https://en.wikipedia.org/wiki/Latin-1_Supplement) character in the range of (`0x20 - 0x7e`, or `0xa0 - 0xff`)
```js
copycat.oneOf('foo', ['red', 'green', 'blue'])
// => 'red'
copycat.scramble('Zakary Hessel')
// => 'Wradls Kbicbs'
```
### `times(input, range, fn)`
#### `options`
Takes in an [`input`](#input) value and a function `fn`, calls that function repeatedly (each time with a unique input) for a number of times within the given `range`, and returns the results as an array:
- **preserve**: An array of characters that should remain the same if present in the given input string
```js
copycat.times('foo', [4, 5], copycat.word)
// => [ 'Raeko', 'Vame', 'Kiyumo', 'Koviva', 'Kiyovami' ]
copycat.scramble('foo@bar.org', { preserve: ['@', '.'] })
// => 'oxb@fmc.ahs'
```
As shown above, `range` can be a tuple array of the minimum and maximum possible number of times the maker should be called. It can also be given as a number, in which case `fn` will be called exactly that number of times:
### `copycat.oneOf(input, values)`
Takes in an [`input`](#input) value and an array of `values`, and returns an item in `values` that corresponds to that `input`:
```js
copycat.times('foo', 2, copycat.word)
// => [ 'Raeko', 'Vame' ]
copycat.oneOf('foo', ['red', 'green', 'blue'])
// => 'red'
```
### `copycat.int(input[, options])`

@@ -107,3 +116,3 @@

```js
int('foo')
copycat.int('foo')
// => 2196697842

@@ -145,3 +154,3 @@ ```

### `copycat.hex(input)`
### `copycat.digit(input)`

@@ -420,2 +429,30 @@ Takes in an [`input`](#input) value and returns a string with a single digit value.

**note** For simplicity, this is currently working off of a list of 500 pre-defined user agent strings. If this is too limiting
for your needs and you need something more dynamic than this, please let us know, and feel free to contribute :)
for your needs and you need something more dynamic than this, please let us know, and feel free to contribute :)
### `copycat.times(input, range, fn)`
Takes in an [`input`](#input) value and a function `fn`, calls that function repeatedly (each time with a unique input) for a number of times within the given `range`, and returns the results as an array:
```js
copycat.times('foo', [4, 5], copycat.word)
// => [ 'Raeko', 'Vame', 'Kiyumo', 'Koviva', 'Kiyovami' ]
```
As shown above, `range` can be a tuple array of the minimum and maximum possible number of times the maker should be called. It can also be given as a number, in which case `fn` will be called exactly that number of times:
```js
copycat.times('foo', 2, copycat.word)
// => [ 'Raeko', 'Vame' ]
### `copycat.setSalt(string)`
Uses the given `string` value as salt when copycat hashes input values. Helpful for changing the generated results.
```js
copycat.fullName('foo')
// => 'Zakary Hessel'
copycat.setSalt('something-else')
copycat.fullName('foo')
// => 'Damion Brown'
```

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