js-search-array

1.0.1 • Public • Published

js-search-array

js-search-array is a small library to search a striing in an array of objects or strings.

Installation

Installation through npm

$ npm install js-search-array

Usage

  import jsStringArray from 'js-string-array'
  import jsStringArray from 'js-string-array';
 
  // Find string in an array of strings
  
  let stringArray = [
    'Delhi',
    'Tamil Nadu',
    'Karnataka',
    'Uttar Pradesh'
  ]
      
  jsStringArray('Ta', stringArray); // => ['Tamil Nadu', 'Karnataka', 'Uttar Pradesh']
 
  // Find string in an array of objects with the key name to match with
    
  let objectArray = [
    {
        name: 'Delhi',
        number: 1
    },
    {
        name: 'Uttarkhand',
        number: 2
    },
    {
        name: 'Himachal Pradesh',
        number: 3
    },
    {
        name: 'Rajasthan',
        number: 4
    }
  ]
    
  jsStringArray('hi', objectArray, 'name'); // => [{name: 'Delhi', number: 1}. {name: 'Himachal Pradesh', number: 3}]

Licence

MIT

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i js-search-array

      Weekly Downloads

      0

      Version

      1.0.1

      License

      MIT

      Unpacked Size

      1.6 kB

      Total Files

      3

      Last publish

      Collaborators

      • nipunjain