JSPM

filter-type

0.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 55
  • Score
    100M100P100Q63484F
  • License

Filter an array or arguments by JavaScript native type (e.g. functions, strings, etc).

Package Exports

  • filter-type

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (filter-type) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

filter-type NPM version Build Status

Filter an array or arguments by JavaScript native type (e.g. functions, strings, etc).

Install with npm

npm i filter-type --save

Usage

var filter = require('filter-type');
filter(array, type);

Params

  • array The array to filter
  • type Native JavaScript type to filter by (e.g. string, function etc)

Example

var arr = [1, 'a', {aaa: 'bbb'}, 3, 'b', 'c', 7, ['foo', 'bar'], function one(){}];

filter(arr, 'object');
//=> [{aaa: 'bbb'}]

filter(arr, 'array');
//=> [['foo', 'bar']]

filter(arr, 'number');
//=> [1, 3, 7]

filter(arr, 'string');
//=> ['a', 'b', 'c']

filter(arr, 'function');
//=> [function one(){}]

Similar projects

  • kind-of: Get the native type of a value.
  • filter-keys: Filter the keys of an object using glob patterns.
  • filter-object: Return a copy of an object, filtered to have only keys that match the given glob patterns.
  • filter-values: Filter an object to have only the own properties for which a callback function returns true.

Running tests

Install dev dependencies.

npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert
Released under the MIT license


This file was generated by verb-cli on March 22, 2015.