Skip to content

Commit 9f89187

Browse files
committed
refactor: typescript and microbundle
1 parent 4557e54 commit 9f89187

16 files changed

+10504
-3101
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
node_modules
2-
build
2+
dist

.npmignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

babel.config.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"env": {
3+
"test": {
4+
"presets": [
5+
[
6+
"@babel/env",
7+
{
8+
"targets": {
9+
"node": "current"
10+
}
11+
}
12+
],
13+
[
14+
"@babel/preset-typescript"
15+
]
16+
],
17+
"plugins": [
18+
"@babel/plugin-transform-modules-commonjs"
19+
]
20+
}
21+
}
22+
}

package-lock.json

Lines changed: 10400 additions & 3026 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
11
{
22
"name": "@nerdo/utils",
3-
"version": "0.0.1",
43
"description": "nerdo's JavaScript utilities.",
5-
"main": "build/nerdo-utils.js",
6-
"scripts": {
7-
"test": "jest",
8-
"build": "rm -rf build/* && rollup -c",
9-
"prepublish": "npm run build"
10-
},
4+
"version": "1.0.0",
115
"author": "Dannel Albert <[email protected]>",
126
"license": "MIT",
137
"repository": {
148
"type": "git",
159
"url": "https://github.com/nerdo/js-utils.git"
1610
},
17-
"devDependencies": {
18-
"@babel/plugin-transform-modules-commonjs": "^7.7.0",
19-
"@babel/preset-env": "^7.7.7",
20-
"jest": "^24.9.0",
21-
"rollup": "^1.27.13",
22-
"rollup-plugin-babel": "^4.3.3",
23-
"rollup-plugin-terser": "^5.1.3"
11+
"main": "dist/nerdo-utils.js",
12+
"umd:main": "dist/nerdo-utils.umd.js",
13+
"module": "dist/nerdo-utils.m.js",
14+
"esmodule": "dist/nerdo-utils.modern.js",
15+
"types": "dist/types/index.d.ts",
16+
"files": [
17+
"dist/*"
18+
],
19+
"scripts": {
20+
"test": "jest",
21+
"build": "microbundle",
22+
"watch": "microbundle -w",
23+
"prepublishOnly": "jest && microbundle"
2424
},
25-
"babel": {
26-
"env": {
27-
"test": {
28-
"plugins": [
29-
"@babel/plugin-transform-modules-commonjs"
30-
]
31-
}
32-
},
33-
"presets": [
34-
[
35-
"@babel/env"
36-
]
37-
]
25+
"devDependencies": {
26+
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
27+
"@babel/preset-env": "^7.10.4",
28+
"@babel/preset-typescript": "^7.10.4",
29+
"@types/jest": "^26.0.4",
30+
"jest": "^26.1.0",
31+
"microbundle": "^0.12.2",
32+
"standard": "^14.3.4"
3833
}
3934
}

rollup.config.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/DayOfWeek.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/DayOfWeek.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export enum DayOfWeek {
2+
Sunday = 0,
3+
Monday = 1,
4+
Tuesday = 2,
5+
Wednesday = 3,
6+
Thursday = 4,
7+
Friday = 5,
8+
Saturday = 6
9+
}
10+
11+
module.exports.DayOfWeek = DayOfWeek
12+
export default DayOfWeek

src/get.test.js renamed to src/get.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ describe('get', () => {
66
})
77

88
it('should return undefined when given no arguments', () => {
9+
// @ts-ignore
910
expect(get()).toBeUndefined()
1011
})
1112

1213
it('should return the object when given no path', () => {
1314
const obj = {}
15+
// @ts-ignore
1416
expect(get(obj)).toBe(obj)
1517
})
1618

src/get.js renamed to src/get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const get = function (obj, path, defaultValue) {
1+
export const get = function (obj: object, path: string | Array<string>, defaultValue?: unknown): unknown {
22
const pathParts = Array.isArray(path) ? path : (typeof path === 'string' ? path.split('.') : [])
33
return pathParts.reduce(
44
(o, key) => typeof o === 'undefined' ? defaultValue : o[key],

0 commit comments

Comments
 (0)