diff options
Diffstat (limited to 'node_modules/css-unit-converter')
| -rw-r--r-- | node_modules/css-unit-converter/CHANGELOG.md | 15 | ||||
| -rw-r--r-- | node_modules/css-unit-converter/LICENSE | 20 | ||||
| -rw-r--r-- | node_modules/css-unit-converter/README.md | 26 | ||||
| -rw-r--r-- | node_modules/css-unit-converter/index.d.ts | 10 | ||||
| -rw-r--r-- | node_modules/css-unit-converter/index.js | 127 | ||||
| -rw-r--r-- | node_modules/css-unit-converter/package.json | 29 |
6 files changed, 227 insertions, 0 deletions
diff --git a/node_modules/css-unit-converter/CHANGELOG.md b/node_modules/css-unit-converter/CHANGELOG.md new file mode 100644 index 00000000..0bd248c4 --- /dev/null +++ b/node_modules/css-unit-converter/CHANGELOG.md @@ -0,0 +1,15 @@ +# 1.1.2 - 2020-05-16
+
+* Add TypeScript definitions (thanks to @seaneking)
+
+# 1.1.1 - 2017-01-25
+
+* Change decimal rounding technique
+
+# 1.1 - 2017-01-24
+
+* Add optional precision argument
+
+# 1.0 - 2015-05-18
+
+* Initial release
diff --git a/node_modules/css-unit-converter/LICENSE b/node_modules/css-unit-converter/LICENSE new file mode 100644 index 00000000..9b1c49b8 --- /dev/null +++ b/node_modules/css-unit-converter/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT)
+
+Copyright 2015 Andy Jansson <andyjansson@users.noreply.github.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file diff --git a/node_modules/css-unit-converter/README.md b/node_modules/css-unit-converter/README.md new file mode 100644 index 00000000..5ea113ef --- /dev/null +++ b/node_modules/css-unit-converter/README.md @@ -0,0 +1,26 @@ +# css-unit-converter [![Build Status][ci-img]][ci]
+
+Converts CSS values from one unit to another
+
+[PostCSS]: https://github.com/postcss/css-unit-converter
+[ci-img]: https://travis-ci.org/andyjansson/css-unit-converter.svg
+[ci]: https://travis-ci.org/andyjansson/css-unit-converter
+
+
+## Installation
+
+```js
+npm install css-unit-converter
+```
+
+## Usage
+
+
+```js
+var convert = require('css-unit-converter');
+//convert 1 inch to pc
+convert(1, 'in', 'pc'); // 6
+
+//convert 10px to cm with a maximum of 10 decimals
+convert(10, 'px', 'cm', 10); // 0.2645833333
+```
diff --git a/node_modules/css-unit-converter/index.d.ts b/node_modules/css-unit-converter/index.d.ts new file mode 100644 index 00000000..f8b96da7 --- /dev/null +++ b/node_modules/css-unit-converter/index.d.ts @@ -0,0 +1,10 @@ +declare module 'css-unit-converter' {
+ export type CSSUnits = 'px' | 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'deg' | 'grad' | 'rad' | 'turn' | 's' | 'ms' | 'Hz' | 'kHz' | 'dpi' | 'dpcm' | 'dppx';
+
+ export default function (
+ value: number,
+ sourceUnit: CSSUnits,
+ targetUnit: CSSUnits,
+ precision?: number
+ ): number;
+}
diff --git a/node_modules/css-unit-converter/index.js b/node_modules/css-unit-converter/index.js new file mode 100644 index 00000000..2bdf1a13 --- /dev/null +++ b/node_modules/css-unit-converter/index.js @@ -0,0 +1,127 @@ +var conversions = {
+ // length
+ 'px': {
+ 'px': 1,
+ 'cm': 96.0/2.54,
+ 'mm': 96.0/25.4,
+ 'in': 96,
+ 'pt': 96.0/72.0,
+ 'pc': 16
+ },
+ 'cm': {
+ 'px': 2.54/96.0,
+ 'cm': 1,
+ 'mm': 0.1,
+ 'in': 2.54,
+ 'pt': 2.54/72.0,
+ 'pc': 2.54/6.0
+ },
+ 'mm': {
+ 'px': 25.4/96.0,
+ 'cm': 10,
+ 'mm': 1,
+ 'in': 25.4,
+ 'pt': 25.4/72.0,
+ 'pc': 25.4/6.0
+ },
+ 'in': {
+ 'px': 1.0/96.0,
+ 'cm': 1.0/2.54,
+ 'mm': 1.0/25.4,
+ 'in': 1,
+ 'pt': 1.0/72.0,
+ 'pc': 1.0/6.0
+ },
+ 'pt': {
+ 'px': 0.75,
+ 'cm': 72.0/2.54,
+ 'mm': 72.0/25.4,
+ 'in': 72,
+ 'pt': 1,
+ 'pc': 12
+ },
+ 'pc': {
+ 'px': 6.0/96.0,
+ 'cm': 6.0/2.54,
+ 'mm': 6.0/25.4,
+ 'in': 6,
+ 'pt': 6.0/72.0,
+ 'pc': 1
+ },
+ // angle
+ 'deg': {
+ 'deg': 1,
+ 'grad': 0.9,
+ 'rad': 180/Math.PI,
+ 'turn': 360
+ },
+ 'grad': {
+ 'deg': 400/360,
+ 'grad': 1,
+ 'rad': 200/Math.PI,
+ 'turn': 400
+ },
+ 'rad': {
+ 'deg': Math.PI/180,
+ 'grad': Math.PI/200,
+ 'rad': 1,
+ 'turn': Math.PI*2
+ },
+ 'turn': {
+ 'deg': 1/360,
+ 'grad': 1/400,
+ 'rad': 0.5/Math.PI,
+ 'turn': 1
+ },
+ // time
+ 's': {
+ 's': 1,
+ 'ms': 1/1000
+ },
+ 'ms': {
+ 's': 1000,
+ 'ms': 1
+ },
+ // frequency
+ 'Hz': {
+ 'Hz': 1,
+ 'kHz': 1000
+ },
+ 'kHz': {
+ 'Hz': 1/1000,
+ 'kHz': 1
+ },
+ // resolution
+ 'dpi': {
+ 'dpi': 1,
+ 'dpcm': 1.0/2.54,
+ 'dppx': 1/96
+ },
+ 'dpcm': {
+ 'dpi': 2.54,
+ 'dpcm': 1,
+ 'dppx': 2.54/96.0
+ },
+ 'dppx': {
+ 'dpi': 96,
+ 'dpcm': 96.0/2.54,
+ 'dppx': 1
+ }
+};
+
+module.exports = function (value, sourceUnit, targetUnit, precision) {
+ if (!conversions.hasOwnProperty(targetUnit))
+ throw new Error("Cannot convert to " + targetUnit);
+
+ if (!conversions[targetUnit].hasOwnProperty(sourceUnit))
+ throw new Error("Cannot convert from " + sourceUnit + " to " + targetUnit);
+
+ var converted = conversions[targetUnit][sourceUnit] * value;
+
+ if (precision !== false) {
+ precision = Math.pow(10, parseInt(precision) || 5);
+ return Math.round(converted * precision) / precision;
+ }
+
+ return converted;
+};
diff --git a/node_modules/css-unit-converter/package.json b/node_modules/css-unit-converter/package.json new file mode 100644 index 00000000..a141344e --- /dev/null +++ b/node_modules/css-unit-converter/package.json @@ -0,0 +1,29 @@ +{
+ "name": "css-unit-converter",
+ "version": "1.1.2",
+ "description": "Converts CSS values from one unit to another",
+ "main": "index.js",
+ "scripts": {
+ "test": "node test/test.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/andyjansson/css-unit-converter.git"
+ },
+ "keywords": [
+ "css",
+ "value",
+ "unit",
+ "converter",
+ "convert"
+ ],
+ "author": "Andy Jansson",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/andyjansson/css-unit-converter/issues"
+ },
+ "homepage": "https://github.com/andyjansson/css-unit-converter",
+ "devDependencies": {
+ "tape": "^4.6.3"
+ }
+}
|
