mybase 1.1.35 → 1.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "mybase",
3
- "version": "1.1.35",
3
+ "version": "1.1.37",
4
4
  "description": "",
5
5
  "main": "mybase.js",
6
- "types": "./ip6addr.d.ts",
7
6
  "scripts": {
8
7
  "test": "jest --forceExit --verbose"
9
8
  },
package/ts/index.ts CHANGED
@@ -31,3 +31,5 @@ export * from "./funcs/ensureFolder"
31
31
  export * from "./models/Unixtime"
32
32
  export * from "./models/Timespan"
33
33
  export * from "./models/IPAddress"
34
+
35
+
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.IPAddress = void 0;
7
+ /// <reference path="./../../ip6addr.d.ts" />
7
8
  const debug_1 = __importDefault(require("debug"));
8
9
  const __1 = require("./../");
9
10
  const ip6addr_1 = __importDefault(require("ip6addr"));
@@ -1,3 +1,4 @@
1
+ /// <reference path="./../../ip6addr.d.ts" />
1
2
  import debug from 'debug'
2
3
  import { randomIP, randomIP6, } from "./../"
3
4
  import ip6addr, { Addr, ToStringOpts } from 'ip6addr'
@@ -28,5 +28,6 @@ export declare class Unixtime {
28
28
  toISOString(): string;
29
29
  elapsedSeconds(): number;
30
30
  elapsedMinutes(): number;
31
+ clone(): Unixtime;
31
32
  static try(value: Date | string | number): Unixtime | null;
32
33
  }
@@ -123,6 +123,9 @@ class Unixtime {
123
123
  elapsedMinutes() {
124
124
  return Math.round(this.elapsedSeconds() / 60);
125
125
  }
126
+ clone() {
127
+ return new Unixtime(this.toLongUnixtime());
128
+ }
126
129
  static try(value) {
127
130
  try {
128
131
  return new Unixtime(value);
@@ -99,4 +99,11 @@ describe('Unixtime', () => {
99
99
  const addedUnixtime = unixtime.addYears(1);
100
100
  expect(addedUnixtime.toDate()).toEqual(new Date(date.setFullYear(date.getFullYear() + 1)));
101
101
  });
102
+
103
+ it('clone should create brand new object', () => {
104
+ const unixtime0 = new Unixtime(new Date())
105
+ const unixtime1 = unixtime0.clone();
106
+ expect(unixtime1).not.toBe(unixtime0);
107
+ expect(unixtime0.toDate()).toEqual(unixtime1.toDate());
108
+ });
102
109
  });
@@ -153,6 +153,10 @@ export class Unixtime {
153
153
  return Math.round(this.elapsedSeconds() / 60)
154
154
  }
155
155
 
156
+ clone():Unixtime {
157
+ return new Unixtime(this.toLongUnixtime())
158
+ }
159
+
156
160
 
157
161
  static try(value: Date | string | number): Unixtime | null {
158
162
  try {