geometry-2d
Advanced tools
Comparing version 0.0.7 to 0.0.8
'use strict'; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -72,3 +74,3 @@ | ||
value: function toString() { | ||
return '(' + this.x + ', ' + this.y + ')'; | ||
return '' + this.x + Point.SEP + this.y; | ||
} | ||
@@ -148,2 +150,14 @@ }, { | ||
} | ||
}], [{ | ||
key: 'fromString', | ||
value: function fromString(s) { | ||
var _s$split = s.split(Point.SEP); | ||
var _s$split2 = _slicedToArray(_s$split, 2); | ||
var x = _s$split2[0]; | ||
var y = _s$split2[1]; | ||
return new Point(parseFloat(x), parseFloat(y)); | ||
} | ||
}]); | ||
@@ -154,2 +168,4 @@ | ||
Point.SEP = '~'; | ||
var Vector = function () { | ||
@@ -156,0 +172,0 @@ function Vector(pointA, pointB) { |
{ | ||
"name": "geometry-2d", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/point.js", |
@@ -27,2 +27,10 @@ require('source-map-support').install(); | ||
describe('Point', function () { | ||
describe('toString-fromString', function() { | ||
it('should work', function() { | ||
const ps = [new Point(-3,3.2234), new Point(-1234.3, 23.23), new Point(-Infinity, Infinity), new Point(0,0), new Point(3,2), new Point(1.00000000000000001, -234.00000000000000), new Point(0.0, 0.00000)]; | ||
ps.forEach( (p) => { | ||
assert(Point.fromString(p.toString()).equals(p)); | ||
}); | ||
}); | ||
}); | ||
describe('rotate90Right', function () { | ||
@@ -29,0 +37,0 @@ it('should work' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41826
468