-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgrade compatibility for @most/core
- Loading branch information
Showing
17 changed files
with
2,557 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,21 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"lib": [ | ||
"es5", | ||
"es2015" | ||
], | ||
"target": "es5", | ||
"moduleResolution": "node", | ||
"module": "commonjs", | ||
"declaration": true, | ||
"noImplicitAny": true, | ||
"sourceMap": true, | ||
"noUnusedParameters": true, | ||
"noUnusedLocals": true, | ||
"outDir": "../lib" | ||
}, | ||
"exclude": [ | ||
"../src/**/*.test.ts" | ||
] | ||
} |
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 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"lib": [ | ||
"es5", | ||
"es2015" | ||
], | ||
"target": "es5", | ||
"moduleResolution": "node", | ||
"module": "es2015", | ||
"declaration": true, | ||
"noImplicitAny": true, | ||
"sourceMap": true, | ||
"noUnusedParameters": true, | ||
"noUnusedLocals": true, | ||
"outDir": "../lib.es2015" | ||
}, | ||
"exclude": [ | ||
"../src/**/*.test.ts" | ||
] | ||
} |
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 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
tab_width = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
insert_final_newline = 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,16 @@ | ||
<!-- | ||
Do you need help or have a question? Please ensure your question is thorough. | ||
Found a bug? Please fill out the sections below 👍. | ||
Show some empathy to the person reading your issue. They are volunteers. | ||
--> | ||
|
||
**Code to reproduce the issue:** | ||
|
||
|
||
**Expected behavior:** | ||
|
||
|
||
**Actual behavior:** | ||
|
||
|
||
**Versions of packages used:** |
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,46 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# generated files | ||
lib | ||
lib.es2015 | ||
.tmp | ||
|
||
# other stuff | ||
src/test.ts | ||
.DS_STORE |
Empty file.
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 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- 8 |
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,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/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,10 @@ | ||
# Contributing | ||
|
||
First of all, thank you so much, we need your help. | ||
|
||
## Contributing a fix or feature | ||
|
||
1. Fork the repository | ||
2. Switch to a new branch `git checkout -b [branchName]` | ||
3. Produce your fix or feature | ||
4. Submit a pull request for review |
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,20 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2017 Tylor Steinberger | ||
|
||
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,52 @@ | ||
# most-subject | ||
|
||
Subjects for [`@most/core`](https://github.com/mostjs/core) | ||
|
||
## Get it | ||
```sh | ||
yarn add most-subject | ||
# or | ||
npm install --save most-subject | ||
``` | ||
|
||
## API Documentation | ||
|
||
|
||
#### create\<A\>(): [Sink\<A\>, Stream\<A\>] | ||
#### create\<A, B\>(f: (stream: Stream\<A\>) =\> B): [Sink\<A\>, B] | ||
|
||
Returns an tuple containing a `Sink` and a `Stream`. `Sink` can be | ||
used to imperatively control the events following through the `Stream`. | ||
Optionally a function can be applied to `Stream` and the return value of that | ||
function will be returned as the second tuple value. | ||
|
||
<details> | ||
<summary>See an example</summary> | ||
|
||
```typescript | ||
import { create } from 'most-subject' | ||
import { runEffects, propagateEventTask } from '@most/core' | ||
import { newDefaultScheduler, currentTime } from '@most/scheduler' | ||
|
||
// Create a new `Scheduler` for use in our application. | ||
// Usually you will want to only have 1 scheduler and should be shared across | ||
// your application | ||
const scheduler = newDefaultScheduler() | ||
|
||
// create our sink and our stream | ||
// NOTE: stream is the resulting value of tap(console.log, stream) | ||
const [ sink, stream ] = create(tap<number>(console.log)) | ||
|
||
// Pushes events into our stream | ||
const event = (n: number) => sink.event(currentTime(scheduler), n) | ||
|
||
// activate our stream | ||
runEffects(stream, scheduler) | ||
|
||
// simulate asynchronous data fetching | ||
// and then push values into our stream | ||
Promise.resolve([ 1, 2, 3 ]) | ||
.then(data => data.forEach(event)) | ||
``` | ||
|
||
</details> |
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,43 @@ | ||
{ | ||
"name": "most-subject", | ||
"description": "Subjects for @most/core", | ||
"repository": "https://github.com/mostjs-community/subject", | ||
"version": "0.0.0", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"typings": "lib/index.d.ts", | ||
"jsnext:main": "lib.es2015/index.js", | ||
"module": "lib.es2015/index.js", | ||
"author": "Tylor Steinberger <tlsteinberger167@gmail.com>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@typed/test": "2.5.0", | ||
"@types/node": "8.0.30", | ||
"husky": "0.14.3", | ||
"lint-staged": "4.2.2", | ||
"prettier": "1.7.0", | ||
"typescript": "2.5.2" | ||
}, | ||
"dependencies": { | ||
"@most/core": "0.13.0", | ||
"@most/types": "0.11.1" | ||
}, | ||
"lint-staged": { | ||
"*.ts": [ | ||
"prettier --write --print-width 80 --tab-width 2 --no-semi --single-quote --trailing-comma es5 --parser typescript", | ||
"git add" | ||
] | ||
}, | ||
"scripts": { | ||
"build": "yarn build:commonjs && yarn build:es2015", | ||
"build:commonjs": "tsc -P .config/tsconfig.commonjs.json", | ||
"build:es2015": "tsc -P .config/tsconfig.es2015.json", | ||
"postversion": "git push origin master --tags && npm publish --access=public", | ||
"precommit": "lint-staged", | ||
"preversion": "yarn test && yarn build", | ||
"release:major": "npm version major -m 'chore(package): v%s'", | ||
"release:minor": "npm version minor -m 'chore(package): v%s'", | ||
"test:lint": "prettier --write --print-width 80 --tab-width 2 --no-semi --single-quote --trailing-comma es5 --parser typescript 'src/*.ts' 'src/**/*.ts'", | ||
"test": "typed-test 'src/*.test.ts' 'src/**/*.test.ts'" | ||
} | ||
} |
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 @@ | ||
import { Scheduler, Stream } from '@most/types' | ||
import { Test, describe, given, it } from '@typed/test' | ||
import { currentTime, newDefaultScheduler } from '@most/scheduler' | ||
import { runEffects, tap } from '@most/core' | ||
|
||
import { create } from './create' | ||
|
||
export const test: Test = describe(`create`, [ | ||
it(`returns [Sink<A>, Stream<A>]`, ({ equal }) => { | ||
const values = [1, 2, 3] | ||
const scheduler = newDefaultScheduler() | ||
const [sink, stream] = create<number>() | ||
|
||
setTimeout(() => { | ||
values.forEach(n => sink.event(currentTime(scheduler), n)) | ||
sink.end(currentTime(scheduler)) | ||
}, 0) | ||
|
||
return collectEvents(scheduler, stream).then(equal(values)) | ||
}), | ||
|
||
given(`(Stream<A>) => B`, [ | ||
it(`returns [Sink<A>, B]`, ({ equal }) => { | ||
const values = [1, 2, 3] | ||
const scheduler = newDefaultScheduler() | ||
const [sink, promise] = create((stream: Stream<number>) => | ||
collectEvents<number>(scheduler, stream) | ||
) | ||
|
||
setTimeout(() => { | ||
values.forEach(n => sink.event(currentTime(scheduler), n)) | ||
sink.end(currentTime(scheduler)) | ||
}, 0) | ||
|
||
return promise.then(equal(values)) | ||
}), | ||
]), | ||
]) | ||
|
||
function collectEvents<A>( | ||
scheduler: Scheduler, | ||
stream: Stream<A> | ||
): Promise<Array<A>> { | ||
const events: Array<A> = [] | ||
|
||
return runEffects(tap(x => events.push(x), stream), scheduler).then( | ||
() => events | ||
) | ||
} |
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 @@ | ||
import { MulticastSource, never } from '@most/core' | ||
import { Sink, Stream } from '@most/types' | ||
|
||
export function create<A = any>(): [Sink<A>, Stream<A>] | ||
export function create<A, B>(operator: (stream: Stream<A>) => B): [Sink<A>, B] | ||
|
||
export function create<A, B = Stream<A>>( | ||
f?: (stream: Stream<A>) => B | ||
): [Sink<A>, B] { | ||
const source = new MulticastSource(never()) | ||
|
||
return [source, f === void 0 ? (source as any) as B : f(source)] | ||
} |
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 @@ | ||
export * from './create' |
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,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": [ | ||
"es5", | ||
"es2015" | ||
], | ||
"target": "es5", | ||
"moduleResolution": "node", | ||
"declaration": true, | ||
"noImplicitAny": true, | ||
"sourceMap": true, | ||
"noUnusedParameters": true, | ||
"noUnusedLocals": true | ||
}, | ||
"include": [ | ||
"src/**/*.ts" | ||
] | ||
} |
Oops, something went wrong.