Skip to content

Commit

Permalink
feat: support cjs and esm both by tshy (#6)
Browse files Browse the repository at this point in the history
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
fengmk2 authored Dec 22, 2024
1 parent e6fa357 commit d2352dc
Show file tree
Hide file tree
Showing 21 changed files with 286 additions and 351 deletions.
6 changes: 6 additions & 0 deletions .eslintrc
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"
]
}
17 changes: 17 additions & 0 deletions .github/workflows/nodejs.yml
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 }}
23 changes: 23 additions & 0 deletions .github/workflows/pkg.pr.new.yml
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
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
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 }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ node_modules
build
components
coverage
.tshy*
.eslintcache
dist
4 changes: 0 additions & 4 deletions .jshintignore

This file was deleted.

95 changes: 0 additions & 95 deletions .jshintrc

This file was deleted.

9 changes: 0 additions & 9 deletions .npmignore

This file was deleted.

7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

6 changes: 0 additions & 6 deletions AUTHORS

This file was deleted.

File renamed without changes.
22 changes: 22 additions & 0 deletions LICENSE
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.
80 changes: 34 additions & 46 deletions README.md
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 &lt;[email protected]&gt;
[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).
17 changes: 0 additions & 17 deletions component.json

This file was deleted.

Loading

0 comments on commit d2352dc

Please sign in to comment.