Skip to content

Commit

Permalink
feat: Add an UMD fallback (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO authored Oct 30, 2021
1 parent bf68549 commit 45f1f37
Show file tree
Hide file tree
Showing 10 changed files with 1,376 additions and 88 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Publish
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
publish:
name: Publish
Expand All @@ -16,6 +17,8 @@ jobs:
node-version: current
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Run tests
run: npm test
- name: Publish
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
test:
name: Test
Expand All @@ -18,5 +19,7 @@ jobs:
node-version: ${{ matrix.node_version }}
- name: Install dependencies
run: npm ci --no-audit
- name: Build
run: npm run build
- name: Run tests
run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
npm-debug.*
umd/index.js
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ In some use cases, however, it is required to be able to reliably work with and
Usage
-----

The class is compatible with CommonJS and AMD loaders and is exposed globally as `Long` if neither is available.
The package exports an ECMAScript module with an UMD fallback.

```javascript
```js
import Long from "long";

var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);
Expand All @@ -38,6 +38,8 @@ console.log(longVal.toString());
...
```

Note that mixing ESM and CommonJS is not recommended as it yield different classes with the same functionality.

API
---

Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,4 @@ declare class Long {
xor(other: Long | number | string): Long;
}

export default Long;
export = Long; // compatible with `import Long from "long"`
Loading

0 comments on commit 45f1f37

Please sign in to comment.