Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prefix-matches

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prefix-matches

Find matching keys in a given object, for a given prefix string

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
36K
decreased by-3.32%
Maintainers
2
Weekly downloads
 
Created
Source

Prefix Matches

Find matching keys in a given object, for a given prefix string

Warning: experimental

Installation

npm i --save prefix-matches

then, in your scripts:

const prefixMatches = require('prefix-matches')

Example

const prefixMatches = require('prefix-matches')

// Resolves simple cases
prefixMatches('w', {
	watch: 'watch things',
	build: 'build things'
}) // => [{ watch: 'watch things' }]

// Does not flatten result set
prefixMatches('w', {
	watch: {
		js: 'watch javascript',
		css: 'watch css'
	},
	build: 'build things'
}) // => [{ watch: { js: 'watch javascript', css: 'watch css' }}]

// Resolves nested prefixes
prefixMatches('w.j', {
	watch: {
		js: 'watch javascript',
		css: 'watch css'
	},
	write: {
		js: 'write javascript'
	}
}) // => [{ 'watch.js': 'watch javascript' }, { 'write.js': 'write javascript' }]

// ... and so on
prefixMatches('b.f.j', {
	build: {
		frontend: {
			js: 'build javascript',
			css: 'build css'
		}
	}
}) // => [{ 'build.frontend.js': 'build javascript' }]

Why?

To attempt better prefixing support for the package-scripts project.

Tests

A basic test suite has been authored in AVA, used for its terrifying speed. To run it:

npm test

Keywords

FAQs

Package last updated on 26 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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