positive-number-array

1.2.2 • Public • Published

positive-number-array

Greenkeeper badge Build Status Coverage Status

Parses input (string | array), returning an array of positive numbers. Zero or negative numbers are ignored.

Installation

npm i positive-number-array -S

Dependencies

None. Suitable for usage on nodejs or on the browser, via browserify.

Initialization

const positiveNumberArray = require('positive-number-array');

Usage

Pass a single number or a string or an array or a JSON-stringified array as input, returns a new array of positive numbers.

positiveNumberArray("1,2,3,4,5")
positiveNumberArray("1 2 3 4 5")
positiveNumberArray("1  2  3  4  5 ")
positiveNumberArray("1,2 3 4 5 ")
positiveNumberArray("1 chicken 2 trolls 3 4 5 mylady")
positiveNumberArray([1,2,3,0,0,4,-1,5])
positiveNumberArray("[1,2,3,4,5]")
--> [1,2,3,4,5]
positiveNumberArray(-1)
-->[]
positiveNumberArray(0.5)
-->[0.5]

Tests

Use mocha framework.

Copyright

Copyright 2016 Paul Brewer, Economic and Financial Technology Consulting LLC

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i positive-number-array

Weekly Downloads

2

Version

1.2.2

License

MIT

Unpacked Size

6.52 kB

Total Files

6

Last publish

Collaborators

  • drpaulbrewer