Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
update build config
Browse files Browse the repository at this point in the history
  • Loading branch information
airt committed May 11, 2017
1 parent fa8e62f commit 59bf326
Show file tree
Hide file tree
Showing 7 changed files with 854 additions and 709 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
language: node_js

node_js:
- "5"
- "6"
- "7"

before_script:
- npm run build

script:
- npm run lint
- npm test

after_success:
- npm run coverage
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 airt
Copyright (c) 2016 - 2017 airt

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{
"name": "timeout-ts",
"version": "0.5.0",
"version": "0.6.0",
"description": "timeout as a promise",
"main": "lib/timeout.js",
"types": "lib/timeout.d.ts",
"author": "airt <airtial@gmail.com>",
"license": "MIT",
"homepage": "https://github.com/airt/timeout-ts",
"keywords": [
"timeout",
"promise",
"typescript"
],
"license": "MIT",
"author": "airt <airtial@gmail.com>",
"homepage": "https://github.com/airt/timeout-ts",
"repository": {
"type": "git",
"url": "https://github.com/airt/timeout-ts"
},
"bugs": {
"url": "https://github.com/airt/timeout-ts/issues"
},
"main": "lib/timeout.js",
"types": "lib/timeout.d.ts",
"devDependencies": {
"ava": "^0.18.0",
"ava": "^0.19.0",
"coveralls": "^2.0.0",
"nyc": "^10.0.0",
"rimraf": "^2.0.0",
"tslint": "^4.0.0",
"tslint-config-standard": "^3.0.0",
"typescript": "^2.1.0"
"tslint": "^5.0.0",
"tslint-config-standard": "^5.0.0",
"typescript": "^2.0.0"
},
"scripts": {
"test": "nyc ava",
"lint": "tslint 'src/**/*.ts'",
"build": "tsc",
"clean": "rimraf lib coverage .nyc_output",
"lint": "tslint -p tsconfig.json --type-check 'src/**/*.ts'",
"build": "tsc --outDir lib",
"clean": "rm -rf lib coverage .nyc_output",
"report": "nyc report --reporter=html",
"coverage": "nyc report --reporter=text-lcov | coveralls"
}
Expand Down
44 changes: 20 additions & 24 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
# timeout-ts

[![NPM Version][npm-badge]][npm-url]
[![Build Status][build-badge]][build-status]
[![Test Coverage][coverage-badge]][coverage-result]
[![NPM Version][npm-badge]][npm-url]

timeout as a promise

## installation

`yarn add timeout-ts`

or

`npm install timeout-ts --save`

## usage

```ts
timeout: (ms?: number) => Promise<void>
timeoutTI: (ms?: number) => [Promise<void>, number]
```

```ts
import timeout from 'timeout-ts'

const main = async () => {
(async () => {

const beginTime = Date.now()
// do something

await timeout(100)

const endTime = Date.now()

assert(endTime - beginTime >= 100)

}
// do something after 100 ms

main()
})()
```

## api
Expand All @@ -46,17 +41,17 @@ timeout: (ms?: number) => Promise<void>
```ts
import timeout from 'timeout-ts'

timeout(100).then(() => {
(async () => {
await timeout(100)
// do something
})
})()

async () => {
await timeout(100)
timeout(100).then(() => {
// do something
}
})
```

### timeoutTI
### timeout (with timeout id)

```ts
timeoutTI: (ms?: number) => [Promise<void>, number]
Expand All @@ -67,9 +62,10 @@ import { timeoutTI } from 'timeout-ts'

const [promise, timeoutId] = timeoutTI(100)

promise.then(() => {
(async () => {
await promise
// do something
})
})()

clearTimeout(timeoutId)
```
Expand All @@ -78,9 +74,9 @@ clearTimeout(timeoutId)

MIT

[npm-badge]: https://img.shields.io/npm/v/timeout-ts.svg
[npm-url]: https://www.npmjs.com/package/timeout-ts
[build-badge]: https://img.shields.io/travis/airt/timeout-ts/master.svg
[build-status]: https://travis-ci.org/airt/timeout-ts
[coverage-badge]: https://img.shields.io/coveralls/airt/timeout-ts.svg
[coverage-result]: https://coveralls.io/github/airt/timeout-ts
[npm-badge]: https://img.shields.io/npm/v/timeout-ts.svg
[npm-url]: https://www.npmjs.com/package/timeout-ts
14 changes: 2 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
// https://www.typescriptlang.org/docs/handbook/compiler-options.html
{
"buildOnSave": false,
"compileOnSave": false,
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"jsx": "preserve",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"pretty": true,
"strict": true,
"sourceMap": true,
"declaration": true,
"noImplicitAny": true,
"noImplicitThis": true,
"removeComments": false,
"strictNullChecks": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"lib": ["dom", "es6", "es2017"]
"lib": ["dom", "esnext"]
}
}
7 changes: 1 addition & 6 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// https://palantir.github.io/tslint/rules/
// https://github.com/blakeembrey/tslint-config-standard/blob/master/tslint.js
{
"extends": "tslint-config-standard",
"rules": {
"trailing-comma": [true, { "multiline": "always", "singleline": "never" }],
"linebreak-style": [true, "LF"],
"quotemark": [true, "single", "jsx-double", "avoid-escape"]
}
"extends": "tslint-config-standard"
}
Loading

0 comments on commit 59bf326

Please sign in to comment.