Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including positive-number-array with all npm packages installed. Try it out:

var positiveNumberArray = require("positive-number-array")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

positive-number-array v1.2.0

parse string or array input, returning an array of positive numbers. Ignore zeros or negatives

positive-number-array

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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free