npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yanick/remeda-extra

v0.1.0

Published

A handful of added functions for Remeda

Downloads

3

Readme

@yanick/remeda

This package provides a few functions to the already awesome remeda 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 { pipe }    from 'remeda';               // as usual
import { matches } from '@yanick/remeda-extra'; // yanick-themed bonus feature!

Additional functions

matches(target, matcher)

matches(matcher)(target)

Compares the input with the matcher and returns true if they match. The matcher can be a function (which will be fed the input and is expected to return a boolean), or a value. If the value is an object, the matching will be recursive.

import { pipe } from 'remeda';
import { matches } from '@yanick/remeda-extra';

matches( 'potato', 'potato'); // => true
matches( 'potato', 'turnip'); // => false
matches( 'potato', vegetable => vegetable === 'potato'); // => true
matches({ a: 1, b :2 }, { a: 1 } ); // => true
matches({ 'a': 4, 'b': 5, 'c': 6 }, { 'a': 4, 'c': 6 }) // => true

pipe({a:1,b:2}, R.matches({ a: 1 }) ) // => true
pipe({a:1,b:2}, R.matches({ b: (val) => val < 5 }) ) // => true
pipe({a:1,b:2}, R.matches({ c: 3 }) ) // => false
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.

sample([1,2,3,4],2); // [3,1]
sample([1,2,3,4],{size:5, repeating: true}); // [3,1,2,2,4]
sample([1,2,3,4],{size:5, repeating: false}); // [3,1,2,4]
R.pipe(
  [{a: 5}, {a: 1}, {a: 3}],
  R.sumBy(x => x.a)
) // 9
R.sample(2)([1,2,3,4]); // [3,1]
R.sample({size:5, repeating: true},[1,2,3,4]); // [3,1,2,2,4]
R.sample({size:5, repeating: false},[1,2,3,4]); // [3,1,2,4]