parse-unit

WebJar for parse-unit

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

parse-unit
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

parse-unit
WebJar for parse-unit
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mattdesl/parse-unit

Download parse-unit

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/parse-unit/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>parse-unit</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/parse-unit/
implementation 'org.webjars.npm:parse-unit:1.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/parse-unit/
implementation ("org.webjars.npm:parse-unit:1.0.1")
'org.webjars.npm:parse-unit:jar:1.0.1'
<dependency org="org.webjars.npm" name="parse-unit" rev="1.0.1">
  <artifact name="parse-unit" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='parse-unit', version='1.0.1')
)
libraryDependencies += "org.webjars.npm" % "parse-unit" % "1.0.1"
[org.webjars.npm/parse-unit "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

parse-unit

stable

Parses a number and unit string, eg "20px" into [20, "px"].

var unit = require('parse-unit')

//prints [50, "gold"]
console.log( unit("50 gold") ) 

Usage

NPM

parse(str[, out])

Parses the string and its unit, returning an array containing the number and unit, separated.

"-20 foo" => [-20, "foo"]
"5.5%" => [5.5, "%"]
5 => [5, ""]
"5" => [5, ""]

This will create a new array unless you specify an array to out, which allows you to re-use arrays.

License

MIT, see LICENSE.md for details.

Versions

Version
1.0.1