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

@justinc/no-dups-validator

v1.0.1

Published

Checks for duplicates given an Iterable

Downloads

5

Readme

no-dups-validator Build status NPM version License Semantic Release Js Standard Style

Checks for duplicates given an Iterable.

Install

npm i @justinc/no-dups-validator

Demo

(see tests for more examples)

const noDups = require('@justinc/no-dups-validator')
noDups([1, 2, 3])()
// [ true, [] ]

noDups([1, 2, 3, 2, 1])('Found the following duplicates: ')
// [ false, [ new Error('Found the following duplicates: 2, 1) ] ]

combine-validations

If you're OK with using Folktale Validation, you might be interested in combine-validations.

To use this package with combine-validations you will need to convert its output Tuple<Boolean, Array<Error>> to a Folktale Validation with something like this:

const Validation = require('data.validation')
const noDups = require('@justinc/no-dups-validator')
const combineValidations = require('@justinc/combine-validations')

const { Success, Failure } = Validation

const asValidation = ([isValid, errors]) => isValid ? Success(true) : Failure(errors)

const input = ['hello', 'world', 'hello']
const validation = combineValidations([
  asValidation(noDups(input)())
])

Tutorials

TODO: A JSDoc 3 tutorial (re currying) needs to be injected in this README.md. For now there's only a link:

  • tutorial: curry.md
  • issue: jsdoc2md/jsdoc-to-markdown#115

Modules

@justinc/no-dups-validator

@justinc/no-dups-validator~noDups([iterable], [errMsgPrefix]) ⇒ Tuple.<Boolean, Array.<Error>>

This function is curried.

Kind: inner method of @justinc/no-dups-validator
See: Tuple

| Param | Type | Default | Description | | --- | --- | --- | --- | | [iterable] | Iterable | [] | The iterable whose elements are checked for duplicates | | [errMsgPrefix] | String | '' | A string to prefix any found duplicates in the error message |

@justinc/jsdocs

This module houses JSDoc 3 type definitions which can be re-used in different packages.

@justinc/jsdocs.Tuple : Array

The type Tuple is an Array of fixed length whose elements at specific indices are of the specified types.

Kind: static typedef of @justinc/jsdocs
Example

// A Tuple of arity (length) 2, whose first el is a Boolean and second el is
// an Array of Error:
Tuple<Boolean, Array<Error>>
// e.g. [ true, [] ]
// e.g. [ false, [ new Error('computer says no') ] ]

Example

// A Tuple of arity (length) 3, whose first el is a String, and both the
// second and third els are an Array of String:
Tuple<String, Array<String>, Array<String>>
// e.g. [ 'hello', [ 'world' ], [ 'goodbye', 'world' ] ]