@vedanshshetti/zeit 1.0.0 → 1.1.0

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,23 +1,29 @@
1
- {
2
- "name": "@vedanshshetti/zeit",
3
- "version": "1.0.0",
4
- "description": "A free, typed Date & Time libraru",
5
- "keywords": [
6
- "zeit"
7
- ],
8
- "homepage": "https://github.com/vedanshshetti/zeit#readme",
9
- "bugs": {
10
- "url": "https://github.com/vedanshshetti/zeit/issues"
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/vedanshshetti/zeit.git"
15
- },
16
- "license": "EUPL-1.2",
17
- "author": "Vedansh Shetti <vedansh.shetti@gmail.com>",
18
- "type": "module",
19
- "main": "dist/index.js",
20
- "scripts": {
21
- "test": "echo \"Error: no test specified\" && exit 1"
22
- }
23
- }
1
+ {
2
+ "name": "@vedanshshetti/zeit",
3
+ "version": "1.1.0",
4
+ "description": "A free, typed Date & Time library",
5
+ "keywords": [
6
+ "zeit"
7
+ ],
8
+ "homepage": "https://github.com/vedanshshetti/zeit#readme",
9
+ "bugs": {
10
+ "url": "https://github.com/vedanshshetti/zeit/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/vedanshshetti/zeit.git"
15
+ },
16
+ "license": "EUPL-1.2",
17
+ "author": "Vedansh Shetti <vedansh.shetti@gmail.com>",
18
+ "type": "module",
19
+ "main": "dist/index.js",
20
+ "scripts": {
21
+ "test": "echo \"Error: no test specified\" && exit 1"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^26.6.6"
25
+ },
26
+ "dependencies": {
27
+ "typescript": "^7.0.2"
28
+ }
29
+ }
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- import before from "./modules/before";
2
- import inX from "./modules/in";
3
- import now from "./modules/now";
1
+ import before from "./modules/before.js";
2
+ import inX from "./modules/in.js";
3
+ import now from "./modules/now.js";
4
4
 
5
5
  export const zeit = {
6
6
  in: inX,
@@ -1,4 +1,4 @@
1
- import { zeit } from "./index";
1
+ import { zeit } from "./index.js";
2
2
 
3
3
  console.log(
4
4
  'zeit.before("5 hours").toString(): ',
@@ -1,5 +1,5 @@
1
- import { parseWording } from "../stuff";
2
- import { Wording } from "../types";
1
+ import { parseWording } from "../stuff.js";
2
+ import type { Wording } from "../types.js";
3
3
 
4
4
  const before = (words: Wording) => {
5
5
  const now = new Date();
package/src/modules/in.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { parseWording } from "../stuff";
2
- import { Wording } from "../types";
1
+ import { parseWording } from "../stuff.js";
2
+ import type { Wording } from "../types.js";
3
3
 
4
4
  const inX = (words: Wording) => {
5
5
  const now = new Date();
@@ -1,4 +1,4 @@
1
- import { toLocalISOString } from "../stuff";
1
+ import { toLocalISOString } from "../stuff.js";
2
2
 
3
3
  type MNum = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
4
4
 
package/src/stuff.ts CHANGED
@@ -1,18 +1,21 @@
1
- import { UnitOfTime, Wording } from "./types";
1
+ import type { UnitOfTime, Wording } from "./types.js";
2
2
 
3
3
  /**
4
4
  * @private
5
5
  */
6
6
  export function parseWording(x: Wording) {
7
- const pieces = x.split(" ");
8
- if(x.startsWith("in")) return {
9
- value: parseInt(pieces[1]) as number,
10
- unit: pieces[2] as UnitOfTime
11
- };
7
+ const pieces = x.split(" ") as [string, string];
8
+ if (pieces.length !== 2) {
9
+ throw new Error(`Invalid wording format: "${x}". Expected format: "<number> <unit>"`);
10
+ }
11
+ const value = parseInt(pieces[0], 10);
12
+ if (isNaN(value)) {
13
+ throw new Error(`Invalid number in wording: "${x}"`);
14
+ }
12
15
  return {
13
- value: parseInt(pieces[0]) as number,
16
+ value,
14
17
  unit: pieces[1] as UnitOfTime
15
- }
18
+ };
16
19
  }
17
20
 
18
21
  export function toLocalISOString(d: Date): string {
package/tsconfig.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Environment Settings
4
+ "module": "nodenext",
5
+ "target": "esnext",
6
+ "lib": ["esnext"],
7
+ "types": ["node"],
8
+
9
+ // Output Layout
10
+ "outDir": "./dist",
11
+ "rootDir": "./src",
12
+ "sourceMap": true,
13
+ "declaration": true,
14
+ "declarationMap": true,
15
+
16
+ // Stricter Typechecking
17
+ "strict": true,
18
+ "noUncheckedIndexedAccess": true,
19
+ "exactOptionalPropertyTypes": true,
20
+ "noImplicitReturns": true,
21
+ "noImplicitOverride": true,
22
+ "noUnusedLocals": true,
23
+ "noUnusedParameters": true,
24
+ "noFallthroughCasesInSwitch": true,
25
+ "noPropertyAccessFromIndexSignature": true,
26
+
27
+ // Module & Syntax
28
+ "verbatimModuleSyntax": true,
29
+ "isolatedModules": true,
30
+ "moduleDetection": "force",
31
+ "skipLibCheck": true,
32
+ "esModuleInterop": true,
33
+ "forceConsistentCasingInFileNames": true
34
+ },
35
+ "include": ["src/**/*"],
36
+ "exclude": ["node_modules", "dist"]
37
+ }