From 2c808efcacc1312b05546cbe9861d06a450c73c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Angel=20Gomez?= Date: Tue, 23 Apr 2024 21:37:44 -0400 Subject: [PATCH] Add comments to pick field --- .github/workflows/dev.yml | 2 -- package.json | 2 +- src/Chaca.ts | 13 +++++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index f43be82..43ffb86 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -2,8 +2,6 @@ name: 🖥️ Workflow Dev on: push: branches: [chaca-dev] - pull_request: - branches: [chaca-dev] jobs: release: name: 🖥️ Dev diff --git a/package.json b/package.json index 706abd5..afad926 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chaca", - "version": "1.9.0", + "version": "1.9.1", "description": "Create and export mock data with your rules", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.mjs", diff --git a/src/Chaca.ts b/src/Chaca.ts index 593949e..7c92208 100644 --- a/src/Chaca.ts +++ b/src/Chaca.ts @@ -184,6 +184,19 @@ export class Chaca { return new ProbabilityField(options); } + /** + * Select a number of elements in an array so that all selected values are not repeated + * + * @param props.values array of values + * @param props.count number of items to select + * + * @example + * chaca.pick({ + * values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], + * count: 3 + * }) + * // [2, 6, 10] or [4, 5, 1] or [1, 9, 8] or ... + */ pick(props: PickFieldProps) { return new PickField(props); }