get-unit

Naive way to check what the unit of a passed quantity is

Usage no npm install needed!

<script type="module">
  import getUnit from 'https://cdn.skypack.dev/get-unit';
</script>

README

get-unit Build Status

Naive way to check what the unit of a given quantity is

Installation

$ npm install get-unit --save

Usage

var getUnit = require('get-unit');

getUnit('5 mm');
//=> 'mm'

getUnit('1.004 A');
//=> 'A'

getUnit('1,4km');
//=> 'km'

getUnit('.4V');
//=> 'V'

getUnit('4');
//=> null

License

MIT © Arthur Verschaeve