-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support cjs and esm both by tshy (#6)
BREAKING CHANGE: drop Node.js < 18.19.0 support part of eggjs/egg#3644 eggjs/egg#5257 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new workflows for continuous integration, package publishing, and release management. - Added TypeScript support with a new configuration file and strict type-checking. - New `pending` function implemented for managing callback execution limits. - **Bug Fixes** - Corrected function name from `pedding` to `pending` in usage examples. - **Documentation** - Updated `README.md` with new badges and improved usage examples. - Added MIT License to the project. - **Chores** - Removed outdated files and configurations, including `.jshintignore`, `.travis.yml`, `AUTHORS`, and `component.json`. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
21 changed files
with
286 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": [ | ||
"eslint-config-egg/typescript", | ||
"eslint-config-egg/lib/rules/enforce-node-prefix" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
Job: | ||
name: Node.js | ||
uses: node-modules/github-actions/.github/workflows/node-test.yml@master | ||
with: | ||
os: 'ubuntu-latest' | ||
version: '18.19.0, 18, 20, 22, 23' | ||
secrets: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Publish Any Commit | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- run: corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build | ||
run: npm run prepublishOnly --if-present | ||
|
||
- run: npx pkg-pr-new publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
|
||
jobs: | ||
release: | ||
name: Node.js | ||
uses: node-modules/github-actions/.github/workflows/node-release.yml@master | ||
secrets: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
GIT_TOKEN: ${{ secrets.GIT_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ node_modules | |
build | ||
components | ||
coverage | ||
.tshy* | ||
.eslintcache | ||
dist |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2011-2014 fengmk2 | ||
Copyright (c) 2024-present node-modules and the contributors. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,69 @@ | ||
# pedding | ||
|
||
[![NPM version][npm-image]][npm-url] | ||
[![build status][travis-image]][travis-url] | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![Gittip][gittip-image]][gittip-url] | ||
[![David deps][david-image]][david-url] | ||
[![node version][node-image]][node-url] | ||
[![Node.js CI](https://github.com/node-modules/pedding/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/pedding/actions/workflows/nodejs.yml) | ||
[![Test coverage][codecov-image]][codecov-url] | ||
[![npm download][download-image]][download-url] | ||
[![Node.js Version](https://img.shields.io/node/v/pedding.svg?style=flat)](https://nodejs.org/en/download/) | ||
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com) | ||
|
||
[npm-image]: https://img.shields.io/npm/v/pedding.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/pedding | ||
[travis-image]: https://img.shields.io/travis/node-modules/pedding.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/node-modules/pedding | ||
[coveralls-image]: https://img.shields.io/coveralls/node-modules/pedding.svg?style=flat-square | ||
[coveralls-url]: https://coveralls.io/r/node-modules/pedding?branch=master | ||
[gittip-image]: https://img.shields.io/gittip/fengmk2.svg?style=flat-square | ||
[gittip-url]: https://www.gittip.com/fengmk2/ | ||
[david-image]: https://img.shields.io/david/node-modules/pedding.svg?style=flat-square | ||
[david-url]: https://david-dm.org/node-modules/pedding | ||
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square | ||
[node-url]: http://nodejs.org/download/ | ||
[codecov-image]: https://codecov.io/github/node-modules/pedding/coverage.svg?branch=master | ||
[codecov-url]: https://codecov.io/github/node-modules/pedding?branch=master | ||
[download-image]: https://img.shields.io/npm/dm/pedding.svg?style=flat-square | ||
[download-url]: https://npmjs.org/package/pedding | ||
|
||
Useful tools for unit test: Just pedding for callback. | ||
Useful tools for unit test: Just pending for callback. | ||
|
||
## Installation | ||
|
||
### Node.js | ||
|
||
```bash | ||
$ npm install pedding | ||
npm install pedding | ||
``` | ||
|
||
### [Component](https://github.com/component/component) | ||
## Usage | ||
|
||
```bash | ||
$ component install node-modules/pedding | ||
CommonJS | ||
|
||
```js | ||
const { pending } = require('pedding'); | ||
|
||
it('should request two resources', done => { | ||
done = pending(2, done); | ||
http.get('http://fengmk2.github.com', res => { | ||
done(); | ||
}); | ||
http.get('http://www.taobao.com', res => { | ||
done(); | ||
}); | ||
}); | ||
``` | ||
|
||
## Usage | ||
ESM and TypeScript | ||
|
||
```js | ||
var pedding = require('pedding'); | ||
```ts | ||
import { pending } from 'pedding'; | ||
|
||
it('should request two resources', function (done) { | ||
done = pedding(2, done); | ||
http.get('http://fengmk2.github.com', function (res) { | ||
it('should request two resources', done => { | ||
done = pending(2, done); | ||
http.get('http://fengmk2.github.com', res => { | ||
done(); | ||
}); | ||
http.get('http://www.taobao.com', function (res) { | ||
http.get('http://www.taobao.com', res => { | ||
done(); | ||
}); | ||
}); | ||
``` | ||
|
||
## License | ||
|
||
(The MIT License) | ||
|
||
Copyright (c) 2011-2014 fengmk2 <[email protected]> | ||
[MIT](LICENSE) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
## Contributors | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
[![Contributors](https://contrib.rocks/image?repo=node-modules/pedding)](https://github.com/node-modules/pedding/graphs/contributors) | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
Made with [contributors-img](https://contrib.rocks). |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.