imperial-metric
Advanced tools
Comparing version 1.1.2 to 1.2.0
46
index.js
@@ -0,1 +1,3 @@ | ||
var IMPERIAL = "imperial"; | ||
var MERTRIC = "metric"; | ||
@@ -6,3 +8,3 @@ var ImperialMetric = function(val) { | ||
inch: { | ||
belong: "imperial", | ||
belong: IMPERIAL, | ||
toMain: 1, | ||
@@ -12,3 +14,3 @@ toOthers: (2.54 / 100) | ||
foot: { | ||
belong: "imperial", | ||
belong: IMPERIAL, | ||
toMain: 12, | ||
@@ -18,3 +20,3 @@ toOthers: (2.54 / 100) | ||
m: { | ||
belong: "metric", | ||
belong: MERTRIC, | ||
toMain: 1, | ||
@@ -24,3 +26,3 @@ toOthers: (1 / 2.54) * 100 | ||
cm: { | ||
belong: "metric", | ||
belong: MERTRIC, | ||
toMain: 1 / 100, | ||
@@ -30,3 +32,3 @@ toOthers: (1 / 2.54) * 100 | ||
mm: { | ||
belong: "metric", | ||
belong: MERTRIC, | ||
toMain: 1 / 1000, | ||
@@ -36,5 +38,35 @@ toOthers: (1 / 2.54) * 100 | ||
km: { | ||
belong: "metric", | ||
belong: MERTRIC, | ||
toMain: 1000, | ||
toOthers: (1 / 2.54) * 100 | ||
}, | ||
"sqrt-foot": { | ||
belong: IMPERIAL, | ||
toMain: 144, | ||
toOthers: (6.4516 / 10000), | ||
}, | ||
"sqrt-inch": { | ||
belong: IMPERIAL, | ||
toMain: 1, | ||
toOthers: (6.4516 / 10000) | ||
}, | ||
"sqrt-m": { | ||
belong: MERTRIC, | ||
toMain: 1, | ||
toOthers: (1 / 6.4516) * 10000 | ||
}, | ||
"sqrt-cm": { | ||
belong: MERTRIC, | ||
toMain: 1 / 10000, | ||
toOthers: (1 / 6.4516) * 10000 | ||
}, | ||
"sqrt-mm": { | ||
belong: MERTRIC, | ||
toMain: 1 / 1000000, | ||
toOthers: (1 / 6.4516) * 10000 | ||
}, | ||
"sqrt-km": { | ||
belong: MERTRIC, | ||
toMain: 1000000, | ||
toOthers: (1 / 6.4516) * 10000 | ||
} | ||
@@ -45,3 +77,3 @@ } | ||
/* | ||
"inch", "cm", "m", "foot" | ||
"inch", "cm", "m", "foot", "sqrt-m", "sqrt-km", "sqrt-cm", "sqrt-mm", "sqrt-inch", "sqrt-foot" | ||
*/ | ||
@@ -48,0 +80,0 @@ ImperialMetric.prototype.from = function(unit) { |
{ | ||
"name": "imperial-metric", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,3 @@ | ||
# ImperialMetric | ||
# ImperialMetric [![Build Status](https://travis-ci.org/tiansijie/imperial-metric.svg?branch=master)](https://travis-ci.org/tiansijie/imperial-metric) | ||
A module that let you convert imperial to metric and metric to imperial easily | ||
@@ -12,2 +13,3 @@ | ||
``` | ||
includes inch, foot, mm, cm, m, km, sqrt-m, sqrt-cm, sqrt-mm, sqrt-km, sqrt-inch, sqrt-foot | ||
@@ -14,0 +16,0 @@ ## Install |
10
test.js
@@ -39,1 +39,11 @@ var IM = require("./index.js"); | ||
}); | ||
test("1 sqrt foot", function(t) { | ||
t.equal(IM(1).from("sqrt-foot").to("sqrt-inch"), 144, "equal 144 sqrt inch"); | ||
t.equal(IM(1).from("sqrt-foot").to("sqrt-m"), 144 * (6.4516 / 10000), "equal 0.09290304 sqrt foot"); | ||
t.equal(IM(1).from("sqrt-foot").to("sqrt-cm"), 144 * (6.4516 / 10000) * 10000, "equal 929.0304 sqrt cm"); | ||
t.equal(IM(1).from("sqrt-foot").to("sqrt-km"), 144 * (6.4516 / 10000) / 1000000, "equal 0.00000009290304 sqrt km"); | ||
t.equal(IM(1).from("sqrt-foot").to("sqrt-mm"), 144 * (6.4516 / 10000) * 1000000, "equal 92903.04 sqrt mm"); | ||
t.end(); | ||
}); |
4693
6
126
19