Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor with typescript #1

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .autod.conf.js

This file was deleted.

5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "egg"
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
]
}
15 changes: 15 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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:
version: '16.13.0, 16, 18, 20'
15 changes: 15 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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 }}
with:
checkTest: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ results

node_modules
npm-debug.log
lib
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

File renamed without changes.
31 changes: 10 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
# get-ready
=====

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![npm download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/get-ready.svg?style=flat-square
[npm-url]: https://npmjs.org/package/get-ready
[travis-image]: https://img.shields.io/travis/node-modules/ready.svg?style=flat-square
[travis-url]: https://travis-ci.org/node-modules/ready
[codecov-image]: https://codecov.io/github/node-modules/ready/coverage.svg?branch=master
[codecov-url]: https://codecov.io/github/node-modules/ready?branch=master
[david-image]: https://img.shields.io/david/node-modules/ready.svg?style=flat-square
[david-url]: https://david-dm.org/node-modules/ready
[download-image]: https://img.shields.io/npm/dm/get-ready.svg?style=flat-square
[download-url]: https://npmjs.org/package/get-ready

**Fork from [supershabam/ready](https://github.com/supershabam/ready)**

NodeJS mixin to add one-time ready event
one-time ready event object.

## Usage

Using `ready` or `ready.mixin` to add `ready` method to the given object.
Create `ready` event object.

```js
const ready = require('get-ready');
const obj = {};
ready.mixin(obj);
```ts
import Ready from 'get-ready';

const obj = new Ready();

// register a callback
obj.ready(() => console.log('ready'));
Expand All @@ -44,14 +34,14 @@ Register a callback to the callback stack, it will be called when mark as ready,

If the callback is undefined, register will return a promise.

```js
```ts
obj.ready().then(() => console.log('ready'));
obj.ready(true);
```

If it has been ready, the callback will be called immediately.

```js
```ts
// already ready
obj.ready(true);
obj.ready().then(() => console.log('ready'));
Expand All @@ -65,7 +55,7 @@ Mark it as ready, you can simply using `.ready(true)`.

You can also mark it not ready.

```js
```ts
obj.ready(true);
// call immediately
obj.ready(() => console.log('ready'));
Expand All @@ -76,12 +66,11 @@ obj.ready(() => throw 'don\'t run');

When exception throws, you can pass an error object, then the callback will receive it as the first argument.

```js
```ts
obj.ready(err => console.log(err));
obj.ready(new Error('err'));
```


## License

[MIT](LICENSE)
16 changes: 0 additions & 16 deletions appveyor.yml

This file was deleted.

94 changes: 0 additions & 94 deletions index.js

This file was deleted.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,45 @@
"name": "get-ready",
"version": "2.0.1",
"description": "mixin to add one-time ready event callback handler",
"main": "index.js",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"index.js"
"lib"
],
"dependencies": {
"is-type-of": "^1.0.0"
"dependencies": {},
"devDependencies": {
"@eggjs/tsconfig": "^1.3.3",
"@types/mocha": "^10.0.1",
"@types/node": "^20.2.5",
"egg-bin": "^6.4.1",
"eslint": "^8.42.0",
"eslint-config-egg": "^12.2.1",
"typescript": "^5.1.3"
},
"engines": {
"node": ">= 4.0.0"
},
"devDependencies": {
"autod": "^2.7.1",
"egg-bin": "^1.10.3",
"egg-ci": "^1.5.0",
"eslint": "^3.17.1",
"eslint-config-egg": "^3.2.0"
"node": ">= 16.13.0"
},
"scripts": {
"autod": "autod",
"lint": "eslint .",
"test": "npm run lint && egg-bin test",
"cov": "egg-bin cov",
"ci": "npm run lint && npm run cov"
"ci": "egg-bin cov && npm run tsc",
"clean": "tsc -b --clean",
"tsc": "tsc",
"prepublishOnly": "npm run tsc"
},
"repository": {
"type": "git",
"url": "git://github.com/node-modules/ready"
"url": "git://github.com/node-modules/get-ready"
},
"keywords": [
"ready",
"get-ready",
"once",
"event"
],
"author": "fengmk2 <m@fengmk2.com> (http://fengmk2.com)",
"author": "fengmk2 <fengmk2@gmail.com> (https://github.com/fengmk2)",
"license": "MIT",
"bugs": {
"url": "https://github.com/node-modules/ready/issues"
},
"ci": {
"version": "4, 6, 7"
"url": "https://github.com/node-modules/get-ready/issues"
}
}
Loading