haystack

0.1.0 • Public • Published

haystack NPM version

A find and match utility. Search for a string or an array of strings within a string or array or strings.

Getting started

Install the module with: npm install haystack --save

var haystack = require('haystack');

Interface

filter

Creates an array of unique values present in all provided arrays using strict equality for comparisons, i.e. ===.

haystack.filter([1, 2, 3], [5, 2, 1, 4]);
// => [1, 2]
 
haystack.filter('a', ['b', 'a']);
// => ['a']
 
haystack.filter(['a', 'b'], 'a');
// => ['a']
 
haystack.filter(['c', 'd'], ['d', 'e', 'c']);
// => ['c', 'd']
 
haystack.filter(['f', 'g'], 'f, h, i');
// => []
 
haystack.filter(['f', 'g'], 'f, h, i', ',');
// => ['f']

Optionally pass a string separator as a third parameter.

haystack.filter(['f', 'b'], 'a,f,k,l', ',');
// => ['f']
 
haystack.filter(['find', 'exclude'], 'A find and match utility', ' ');
// => ['find']

hasMatch

haystack.filter([1, 2, 3], [5, 2, 1, 4]);
// => true
 
haystack.filter('a', ['b', 'a']);
// => true
 
haystack.filter(['c', 'd'], ['d', 'e', 'c']);
// => true
 
haystack.filter(['f', 'g'], 'f, h, i');
// => false
 
haystack.filter(['f', 'g'], 'f, h, i', ',');
// => true

Contributing

Find a bug? Have a feature request? Please create an Issue.

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt, and build the documentation with grunt-readme.

Pull requests are also encouraged, and if you find this project useful please consider "starring" it to show your support! Thanks!

Related projects

Authors

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors. Released under the MIT license


This file was generated by grunt-readme on Wednesday, January 8, 2014.

Package Sidebar

Install

npm i haystack

Weekly Downloads

2

Version

0.1.0

License

none

Last publish

Collaborators

  • doowb
  • jonschlinkert