-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
毕宇旗
committed
Mar 31, 2021
0 parents
commit 030bdd3
Showing
24 changed files
with
779 additions
and
0 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,14 @@ | ||
# Editor configuration, see http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
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,4 @@ | ||
node_modules | ||
dist | ||
coverage | ||
lib |
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,29 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
node: true | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
sourceType: 'module' | ||
}, | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint', 'prettier'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'prettier/@typescript-eslint', | ||
'plugin:prettier/recommended' | ||
], | ||
rules: { | ||
'prefer-const': [ | ||
'error', | ||
{ | ||
destructuring: 'any', | ||
ignoreReadBeforeAssign: false | ||
} | ||
], | ||
'no-unused-vars': 0 | ||
} | ||
} |
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,27 @@ | ||
.DS_Store | ||
node_modules | ||
dist | ||
coverage | ||
lib | ||
|
||
package-lock.json | ||
yarn.lock | ||
|
||
# local env files | ||
.env.local | ||
.env.*.local | ||
|
||
# Log files | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
|
||
# Editor directories and files | ||
.idea | ||
.vscode | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
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,5 @@ | ||
dist | ||
lib | ||
node_modules | ||
package.json | ||
yarn.lock |
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,8 @@ | ||
module.exports = { | ||
singleQuote: true, | ||
printWidth: 100, | ||
proseWrap: 'never', | ||
semi: false, | ||
trailingComma: 'none', | ||
arrowParens: 'avoid' | ||
} |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 unknow | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Welcome to @ifake/easy-polling 👋 | ||
 | ||
 | ||
 | ||
|
||
> The Class used to compute the next step of data. | ||
The scaffolding for this project is from [pkg](https://github.com/ifakejs/pkg) | ||
|
||
### 🏠 [Homepage](https://github.com/ifakejs/easy-polling) | ||
|
||
### Usage | ||
```sh | ||
import { EasyPolling } from "@ifake/easy-polling"; | ||
|
||
const instance = new EasyPolling({ | ||
source: [param1, param2, param3...], | ||
intervalTime: 2000 // 毫秒 | ||
type: 'single' || 'double' | ||
returnCount: 2 // 每次返回的数据大小 | ||
}) | ||
instance.observe((data) => { | ||
// 根据间隔时长,返回对应的内容 | ||
}) | ||
instance.start() | ||
// stop | ||
instance.stop() | ||
// update intervalTime | ||
instance.updateIntervalTime(5000) | ||
``` | ||
## Author | ||
👤 **BiYuqi** | ||
## 🤝 Contributing | ||
Contributions, issues and feature requests are welcome! | ||
Feel free to check [issues page](https://github.com/ifakejs/easy-polling/issues). | ||
## Show your support | ||
Give a ⭐️ if this project helped you! | ||
## 📝 License | ||
This project is [MIT](https://github.com/ifakejs/easy-loop/blob/master/LICENSE) licensed. | ||
*** | ||
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_ |
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,36 @@ | ||
import { Q } from "../src/Q" | ||
|
||
describe("Q", () => { | ||
let instance: Q | ||
beforeEach(() => { | ||
instance = new Q() | ||
}) | ||
it('enqueue ', () => { | ||
instance.enqueue(1) | ||
expect(instance.queue).toEqual([1]) | ||
}) | ||
|
||
it('enqueue ', () => { | ||
instance.enqueue(1) | ||
expect(instance.dequeue()).toEqual(1) | ||
}) | ||
|
||
it('front ', () => { | ||
instance.enqueue(2) | ||
instance.enqueue(1) | ||
expect(instance.front()).toEqual(2) | ||
}) | ||
|
||
it('clear ', () => { | ||
instance.enqueue(2) | ||
instance.enqueue(1) | ||
instance.clear() | ||
expect(instance.queue).toEqual([]) | ||
}) | ||
|
||
it('isEmpty ', () => { | ||
expect(instance.isEmpty).toEqual(true) | ||
instance.enqueue(2) | ||
expect(instance.isEmpty).toEqual(false) | ||
}) | ||
}) |
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,15 @@ | ||
import { chunk } from "../src/chunk" | ||
|
||
describe("chunk", () => { | ||
it('should return correct error message', () => { | ||
try { | ||
// @ts-ignore | ||
chunk("", 2) | ||
} catch (e) { | ||
expect(e.message).toBe("Required an array.") | ||
} | ||
}); | ||
it('should split array correct', () => { | ||
expect(chunk([1, 2, 3, 4, 5], 2)).toEqual([ [ 1, 2 ], [ 3, 4 ], [ 5 ] ]) | ||
}); | ||
}) |
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,52 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"projectFolder": ".", | ||
"mainEntryPointFilePath": "./temp/src/index.d.ts", | ||
|
||
"apiReport": { | ||
"enabled": true, | ||
"reportFolder": "<projectFolder>/temp/" | ||
}, | ||
|
||
"docModel": { | ||
"enabled": true | ||
}, | ||
|
||
"dtsRollup": { | ||
"enabled": true, | ||
"untrimmedFilePath": "./lib/index.d.ts" | ||
}, | ||
|
||
"tsdocMetadata": { | ||
"enabled": false | ||
}, | ||
|
||
"messages": { | ||
"compilerMessageReporting": { | ||
"default": { | ||
"logLevel": "warning" | ||
} | ||
}, | ||
|
||
"extractorMessageReporting": { | ||
"default": { | ||
"logLevel": "warning", | ||
"addToApiReportFile": true | ||
}, | ||
|
||
"ae-missing-release-tag": { | ||
"logLevel": "none" | ||
} | ||
}, | ||
|
||
"tsdocMessageReporting": { | ||
"default": { | ||
"logLevel": "warning" | ||
}, | ||
|
||
"tsdoc-undefined-tag": { | ||
"logLevel": "none" | ||
} | ||
} | ||
} | ||
} |
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 @@ | ||
module.exports = { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
modules: false, | ||
targets: { node: 'current' } | ||
} | ||
] | ||
], | ||
plugins: ['@babel/plugin-transform-runtime'], | ||
env: { | ||
test: { | ||
plugins: ['@babel/plugin-transform-modules-commonjs'] | ||
} | ||
} | ||
} |
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,39 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<button class="start">开始</button> | ||
<button class="end">结束</button> | ||
<button class="update">改变时间间隔</button> | ||
<script src="dist/index.umd.js"></script> | ||
<script> | ||
const instance = new window.EasyPolling.EasyPolling({ | ||
type: "single", | ||
source: [1, 2, 3, 4, 5], | ||
returnCount: 2, | ||
intervalTime: 2000 | ||
}) | ||
|
||
instance.observe(cb => { | ||
console.log(cb) | ||
}) | ||
|
||
document.querySelector(".start").addEventListener("click", () => { | ||
instance.start() | ||
}) | ||
document.querySelector(".end").addEventListener("click", () => { | ||
instance.stop() | ||
}) | ||
document.querySelector(".update").addEventListener("click", () => { | ||
instance.updateIntervalTime(5000) | ||
}) | ||
|
||
</script> | ||
</body> | ||
</html> |
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 @@ | ||
module.exports = { | ||
verbose: true, | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testRegex: '__test__/(.*|(\\.|/)(test|spec))\\.tsx?$' | ||
} |
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,49 @@ | ||
{ | ||
"name": "@ifake/easy-polling", | ||
"version": "0.0.0", | ||
"description": "", | ||
"main": "dist/index.umd.js", | ||
"module": "lib/index.esm.js", | ||
"scripts": { | ||
"start": "cross-env NODE_ENV=development rollup -c rollup.config.ts -w", | ||
"build": "cross-env NODE_ENV=production rollup -c rollup.config.ts", | ||
"build:types": "tsc -p tsconfig.type.json && api-extractor run && rimraf ./temp", | ||
"test": "jest", | ||
"demo": "serve -l 8986" | ||
}, | ||
"files": [ | ||
"lib", | ||
"dist", | ||
"LICENSE", | ||
"CHANGELOG.md", | ||
"README.md" | ||
], | ||
"LICENSE": "MIT", | ||
"author": "", | ||
"devDependencies": { | ||
"@babel/core": "^7.12.9", | ||
"@babel/plugin-transform-modules-commonjs": "^7.12.1", | ||
"@babel/plugin-transform-runtime": "^7.12.1", | ||
"@babel/preset-env": "^7.12.7", | ||
"@microsoft/api-extractor": "~7.13.2", | ||
"@rollup/plugin-babel": "^5.2.2", | ||
"@rollup/plugin-commonjs": "^17.0.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^11.0.0", | ||
"@rollup/plugin-typescript": "^8.1.0", | ||
"@types/jest": "^26.0.22", | ||
"@types/node": "^14.14.37", | ||
"cross-env": "^7.0.2", | ||
"jest": "^26.6.3", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.34.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"serve": "^11.3.2", | ||
"ts-jest": "^26.5.4", | ||
"tslib": "^2.1.0", | ||
"typescript": "~4.1.5" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.12.5" | ||
} | ||
} |
Oops, something went wrong.