prototype-helper
Advanced tools
Comparing version 0.3.3 to 0.3.5
@@ -93,3 +93,3 @@ "use strict"; | ||
// } | ||
Array.prototype.deepClone = function () { | ||
Array.prototype.deepCopy = function () { | ||
return deep_clone_1.default(this); | ||
@@ -96,0 +96,0 @@ }; |
@@ -18,12 +18,2 @@ "use strict"; | ||
}; | ||
function hexfloatNotation(number, numberPoint = 8) { | ||
const tmp = number.toString().split("."); | ||
if (tmp[1]) { | ||
const size = Math.round(number * Math.pow(10, numberPoint)) / Math.pow(10, numberPoint); | ||
return Number(tmp[0] + size); | ||
} | ||
else { | ||
return Number(tmp); | ||
} | ||
} | ||
Number.prototype.div = function (value) { | ||
@@ -30,0 +20,0 @@ return decimal_js_1.default.div(Number(this), value).toNumber(); |
@@ -7,8 +7,8 @@ "use strict"; | ||
const deep_clone_1 = __importDefault(require("deep-clone")); | ||
Object.prototype.deepClone = function () { | ||
Object.prototype.deepCopy = function () { | ||
return deep_clone_1.default(this); | ||
}; | ||
Object.prototype.stringify = function () { | ||
Object.prototype.toJson = function () { | ||
return JSON.stringify(this); | ||
}; | ||
//# sourceMappingURL=object.js.map |
@@ -17,4 +17,4 @@ interface Array<T> { | ||
lastOrDefault(predicate?: (element: T, index: number) => boolean, defaultValue?: any): T; | ||
deepClone<T>(): T[]; | ||
deepCopy<T>(): T[]; | ||
toJson(): string; | ||
} |
interface Object { | ||
deepClone(): Object; | ||
stringify(): string; | ||
deepCopy(): Object; | ||
toJson(): string; | ||
} |
@@ -94,7 +94,7 @@ "use strict"; | ||
console.log(aaa.toJson()); | ||
const bbb = aaa.deepClone(); | ||
const bbb = aaa.deepCopy(); | ||
const ccc = `[1,2,3,4,5]`; | ||
console.log(aaa, bbb, aaa === bbb); | ||
console.log(ccc.fromJson()); | ||
console.log({ a: 1, b: 3 }.stringify()); | ||
console.log({ a: 1, b: 3 }.toJson()); | ||
console.log((1234.1234).round(2)); | ||
@@ -101,0 +101,0 @@ console.log((1234.1234).floor(2)); |
{ | ||
"name": "prototype-helper", | ||
"version": "0.3.3", | ||
"version": "0.3.5", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -65,4 +65,2 @@ <img src="https://capsule-render.vercel.app/api?type=waving&color=343a40&height=210§ion=header&text=Typescript Prototype Helper&fontSize=50&fontAlignY=35&fontColor=adb5bd" /> | ||
Calculate only up to 15 decimal places. | ||
```ts | ||
@@ -77,4 +75,2 @@ console.log(0.1 + 0.2); // 0.30000000000000004 | ||
Calculate only up to 15 decimal places. | ||
```ts | ||
@@ -89,4 +85,2 @@ console.log(0.1 - 0.3); // -0.19999999999999998 | ||
Calculate only up to 15 decimal places. | ||
```ts | ||
@@ -99,6 +93,4 @@ console.log(0.2 / 0.6); // 0.33333333333333337 | ||
Division that safely handles floating point errors. | ||
Multiply that safely handles floating point errors. | ||
Calculate only up to 15 decimal places. | ||
```ts | ||
@@ -105,0 +97,0 @@ console.log(0.1 * 0.2); // 0.020000000000000004 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
52010
640
199