From c7d33afe9d4176456706e629881d88ab2aab4e21 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Tue, 25 Jul 2023 13:47:16 -0400 Subject: [PATCH] don't re-export remeda itself --- README.md | 27 +++++++++++++++------------ Taskfile.yaml | 2 +- package.json | 12 ++++++------ src/index.ts | 5 ++--- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 229bf75..53509db 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,16 @@ # @yanick/remeda -This package adds a few functions to the already awesome -[remeda](https://remedajs.com/) library. For convenience, it -re-export everything that remeda has. +This package provides a few functions to the already awesome +[remeda](https://remedajs.com/) library that I really want, but wasn't able to +get in Remeda itself. + +## Usage + +Just import the additional functions from `@yanick/remeda-extra`. ``` -import { matches, pipe } from '@yanick/remeda'; - -// equivalent to - -import { pipe } from 'remeda'; -import { matches } from '@yanick/remeda'; - +import { pipe } from 'remeda'; // as usual +import { matches } from '@yanick/remeda-extra'; // yanick-themed bonus feature! ``` ## Additional functions @@ -25,7 +24,8 @@ to return a boolean), or a value. If the value is an object, the matching will be recursive. ``` -import { matches, pipe } from '@yanick/remeda'; +import { pipe } from 'remeda'; +import { matches } from '@yanick/remeda-extra'; matches( 'potato', 'potato'); // => true matches( 'potato', 'turnip'); // => false @@ -42,9 +42,12 @@ pipe( { 'a': 4, 'b': 5, 'c': 6 }, R.matches({ 'a': 4, 'c': 6 })) // => true ### `sample(target, size | { size: number, repeating: boolean })` ### `sample(size | { size: number, repeating: boolean })(target)` +Like the `sample` that comes with Remeda, but this one shuffles its output +automatically. + Returns random elements of the array. If `size` is bigger than the array length and `repeating` is false, returns a number of samples equal to -the size of the whole array. +the size of the whole array. ``` sample([1,2,3,4],2); // [3,1] diff --git a/Taskfile.yaml b/Taskfile.yaml index 0a81e0a..bdc1d3c 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -6,8 +6,8 @@ tasks: build: tsc test: + deps: [ build ] cmds: - - { task: build } - vitest run src pack: npm pack diff --git a/package.json b/package.json index 2bc7692..db9ab09 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { - "name": "@yanick/remeda", + "name": "@yanick/remeda-extra", "version": "0.1.0", - "description": "Remeda, plus a handful of added functions", - "repository": "https://git.babyl.ca/yanick/yanick-remeda.git", + "description": "A handful of added functions for Remeda", + "repository": "https://git.babyl.ca/yanick/remeda-extra.git", "bugs": { - "url": "https:/git.babyl.ca/yanick/yanick-remeda/issues" + "url": "https:/git.babyl.ca/yanick/remeda-extra/issues" }, - "homepage": "https:/git.babyl.ca/yanick/yanick-remeda/issues", + "homepage": "https:/git.babyl.ca/yanick/remeda-extra/issues", "type": "module", - "main": "src/index.js", + "main": "dist/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/src/index.ts b/src/index.ts index a416e5b..4444083 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,2 @@ -export * from 'remeda'; - -export * from './matches'; +export * from './matches.js'; +export * from './sample.js';