├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .lgtm ├── .travis.yml ├── .vscode └── settings.json ├── LICENSE.md ├── MAINTAINERS ├── README.md ├── _scripts ├── new-package.js ├── run-all-packages.js ├── symlink-all-packages.js ├── template │ ├── package.ejs.json │ ├── rollup.config.ejs.js │ ├── src-index.ejs.ts │ ├── test-index.ejs.ts │ ├── tsconfig.json │ └── typings.ejs.json └── update-dependencies.js ├── lerna.json ├── package.json ├── packages ├── combine │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-combine.js │ │ ├── tempest-combine.js.map │ │ └── tempest-combine.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── core │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-core.js │ │ ├── tempest-core.js.map │ │ └── tempest-core.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ ├── Stream.ts │ │ ├── index.ts │ │ ├── interfaces.ts │ │ ├── multicast │ │ │ ├── Multicast.ts │ │ │ ├── MulticastDisposable.ts │ │ │ ├── MulticastTask.ts │ │ │ └── sink.ts │ │ ├── runSource.ts │ │ ├── scheduler │ │ │ ├── BinaryTimeline.ts │ │ │ ├── ClockTimer.ts │ │ │ ├── PredeterminedTask.ts │ │ │ ├── PropagateTask.ts │ │ │ ├── Scheduler.ts │ │ │ └── defaultScheduler.ts │ │ ├── source │ │ │ ├── fromArray.ts │ │ │ └── fromObservable.ts │ │ └── util │ │ │ ├── BasicSubscription.ts │ │ │ ├── IndexSink.ts │ │ │ ├── SubscriberSink.ts │ │ │ ├── array.ts │ │ │ ├── curry.ts │ │ │ ├── fatalError.ts │ │ │ ├── getSource.ts │ │ │ └── task.ts │ ├── test │ │ ├── Stream.ts │ │ └── helpers │ │ │ ├── FakeSink.ts │ │ │ └── FakeSource.ts │ ├── tsconfig.json │ └── typings.json ├── create │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-create.js │ │ ├── tempest-create.js.map │ │ └── tempest-create.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── debug │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-debug.js │ │ ├── tempest-debug.js.map │ │ └── tempest-debug.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── drop │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-drop.js │ │ ├── tempest-drop.js.map │ │ └── tempest-drop.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── empty │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-empty.js │ │ ├── tempest-empty.js.map │ │ └── tempest-empty.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── endWhen │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-endWhen.js │ │ ├── tempest-endWhen.js.map │ │ └── tempest-endWhen.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── filter │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-filter.js │ │ ├── tempest-filter.js.map │ │ └── tempest-filter.min.js │ ├── doc │ │ ├── assets │ │ │ ├── css │ │ │ │ ├── main.css │ │ │ │ └── main.css.map │ │ │ ├── images │ │ │ │ ├── icons.png │ │ │ │ ├── icons@2x.png │ │ │ │ ├── widgets.png │ │ │ │ └── widgets@2x.png │ │ │ └── js │ │ │ │ ├── main.js │ │ │ │ └── search.js │ │ ├── classes │ │ │ ├── _index_.filter.html │ │ │ └── _index_.filtersink.html │ │ ├── globals.html │ │ ├── index.html │ │ ├── interfaces │ │ │ └── _index_.filtercurried.html │ │ └── modules │ │ │ └── _index_.html │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── flatten │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-flatten.js │ │ ├── tempest-flatten.js.map │ │ └── tempest-flatten.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── fold │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-fold.js │ │ ├── tempest-fold.js.map │ │ └── tempest-fold.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── fromPromise │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-fromPromise.js │ │ ├── tempest-fromPromise.js.map │ │ └── tempest-fromPromise.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── last │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-last.js │ │ ├── tempest-last.js.map │ │ └── tempest-last.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── map │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-map.js │ │ ├── tempest-map.js.map │ │ └── tempest-map.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── merge │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-merge.js │ │ ├── tempest-merge.js.map │ │ └── tempest-merge.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── never │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-never.js │ │ ├── tempest-never.js.map │ │ └── tempest-never.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── periodic │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-periodic.js │ │ ├── tempest-periodic.js.map │ │ └── tempest-periodic.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── proxy │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-proxy.js │ │ ├── tempest-proxy.js.map │ │ └── tempest-proxy.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── remember │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-remember.js │ │ ├── tempest-remember.js.map │ │ └── tempest-remember.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── replaceError │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-replaceError.js │ │ ├── tempest-replaceError.js.map │ │ └── tempest-replaceError.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── sample │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-sample.js │ │ ├── tempest-sample.js.map │ │ └── tempest-sample.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── startWith │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-startWith.js │ │ ├── tempest-startWith.js.map │ │ └── tempest-startWith.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── subject │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-subject.js │ │ ├── tempest-subject.js.map │ │ └── tempest-subject.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json ├── take │ ├── CHANGELOG.md │ ├── dist │ │ ├── tempest-take.js │ │ ├── tempest-take.js.map │ │ └── tempest-take.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ └── index.ts │ ├── test │ │ └── index.ts │ ├── tsconfig.json │ └── typings.json └── throwError │ ├── CHANGELOG.md │ ├── dist │ ├── tempest-throwError.js │ ├── tempest-throwError.js.map │ └── tempest-throwError.min.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ └── index.ts │ ├── test │ └── index.ts │ ├── tsconfig.json │ └── typings.json └── tslint.json /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 10 | 11 | **General Problem:** 12 | 13 | **Minimal Code to reproduce:** 14 | 15 | **Expected behavior:** 16 | 17 | **Actual behavior:** 18 | 19 | **Additional information:** -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 10 | 11 | **Description:** 12 | 13 | **Related issue (if exists):** -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | lib/ 3 | *.log 4 | *.log* 5 | typings/ 6 | .released-packages 7 | .dockerignore 8 | .*.dockerfile -------------------------------------------------------------------------------- /.lgtm: -------------------------------------------------------------------------------- 1 | approvals = 1 2 | pattern = "(?i):shipit:|:\\+1:|LGTM" -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 6 -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "editor.fontFamily": "Fira Code Medium", 4 | "editor.tabSize": 2, 5 | "editor.rulers": [80, 160], 6 | "editor.insertSpaces": true, 7 | "editor.wrappingColumn": 160, 8 | "editor.fontLigatures": true, 9 | 10 | "typescript.tsdk": "node_modules/typescript/lib", 11 | "typescript.tsserver.experimentalAutoBuild": true, 12 | 13 | "tslint.configFile": "tslint.json" 14 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2016 Tylor Steinberger 3 | 4 | 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: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | 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. -------------------------------------------------------------------------------- /MAINTAINERS: -------------------------------------------------------------------------------- 1 | Tylor Steinberger (@TylorS) -------------------------------------------------------------------------------- /_scripts/run-all-packages.js: -------------------------------------------------------------------------------- 1 | // node requires 2 | const { execSync: exec } = require('child_process') 3 | const { join } = require('path') 4 | const fs = require('fs') 5 | 6 | // package requires 7 | const mkdirp = require('mkdirp') 8 | const rimraf = require('rimraf') 9 | 10 | // constants 11 | const TEMPEST_DIR=process.cwd() 12 | const PACKAGES_DIR=join(TEMPEST_DIR, 'packages') 13 | const PACKAGES=getDirectories(PACKAGES_DIR) 14 | const SCRIPT = process.argv[2] 15 | 16 | PACKAGES.forEach(package => { 17 | const PACKAGE_DIR = join(PACKAGES_DIR, package) 18 | console.log(`Running '${SCRIPT}' in @tempest/${package}...`) 19 | exec(`npm run ${SCRIPT}`, { cwd: PACKAGE_DIR }) 20 | }) 21 | 22 | function getDirectories (path) { 23 | return fs.readdirSync(path).filter(isDirectoryIn(path)) 24 | } 25 | 26 | function isDirectoryIn (path) { 27 | return function isDirectory (dir) { 28 | return fs.statSync(join(path, dir)).isDirectory() 29 | } 30 | } -------------------------------------------------------------------------------- /_scripts/template/rollup.config.ejs.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-<%= name %>.js', 6 | format: 'umd', 7 | moduleName: 'tempest<%= capitalName %>', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /_scripts/template/src-index.ejs.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Disposable, Scheduler } from '@tempest/core' 2 | 3 | export function <%= name %> (stream: Stream) { 4 | return new Stream(new <%= capitalName %>(stream.source)) 5 | } 6 | 7 | export class <%= capitalName %> implements Source { 8 | constructor (private source: Source) {} 9 | 10 | run (sink: Sink, scheduler: Scheduler): Disposable { 11 | return this.source.run(new <%= capitalName %>Sink(sink), scheduler) 12 | } 13 | } 14 | 15 | class <%= capitalName %>Sink implements Sink { 16 | constructor (private sink: Sink) {} 17 | 18 | event (time: number, value: T) { 19 | this.sink.event(time, value) 20 | } 21 | 22 | error (time: number, err: Error) { 23 | this.sink.error(time, err) 24 | } 25 | 26 | end (time: number, value?: T) { 27 | this.sink.end(time, value) 28 | } 29 | } -------------------------------------------------------------------------------- /_scripts/template/test-index.ejs.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { <%= name %> } from '../src/index' 6 | 7 | describe('@tempest/<%= name %>', () => { 8 | it ('should ', (done) => { 9 | }) 10 | }) -------------------------------------------------------------------------------- /_scripts/template/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /_scripts/template/typings.ejs.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/<%= name %>", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /_scripts/update-dependencies.js: -------------------------------------------------------------------------------- 1 | // node requires 2 | const { execSync: exec } = require('child_process') 3 | const { join } = require('path') 4 | const fs = require('fs') 5 | 6 | // package requires 7 | const mkdirp = require('mkdirp') 8 | const rimraf = require('rimraf') 9 | const Boxcutter = require('boxcutter') 10 | 11 | // constants 12 | const TEMPEST_DIR=process.cwd() 13 | const PACKAGES_DIR=join(TEMPEST_DIR, 'packages') 14 | const PACKAGES = getDirectories(PACKAGES_DIR) 15 | const SCRIPT = process.argv[2] 16 | 17 | PACKAGES.forEach(package => { 18 | const CURRENT_PACKAGE_DIR = join(PACKAGES_DIR, package) 19 | const PACKAGEJSON = require(join(CURRENT_PACKAGE_DIR, 'package.json')) 20 | const DEPENDENCIES = Object.keys(PACKAGEJSON.dependencies) 21 | const DEVDEPENDENCIES = Object.keys(PACKAGEJSON.devDependencies) 22 | 23 | const boxcutter = Object.assign({}, Boxcutter.Boxcutter) 24 | boxcutter.load(join(CURRENT_PACKAGE_DIR, 'package.json')) 25 | function updateDep (dep) { 26 | if (isTempestPackage(dep)) { 27 | const DEP_DIR = join(PACKAGES_DIR, strip(dep)) 28 | const DEP_PACKAGEJSON = require(join(DEP_DIR, 'package.json')) 29 | const VERSION = DEP_PACKAGEJSON.version 30 | console.log(`Updating dependency on ${dep} to v${VERSION} in ${package}`) 31 | boxcutter.set(`dependencies.${dep}`, `^${VERSION}`) 32 | } 33 | } 34 | 35 | DEPENDENCIES.forEach(updateDep) 36 | DEVDEPENDENCIES.forEach(updateDep) 37 | boxcutter.save(join(CURRENT_PACKAGE_DIR, 'package.json')) 38 | }) 39 | 40 | function getDirectories (path) { 41 | return fs.readdirSync(path).filter(isDirectoryIn(path)) 42 | } 43 | 44 | function isDirectoryIn (path) { 45 | return function isDirectory (dir) { 46 | return fs.statSync(join(path, dir)).isDirectory() 47 | } 48 | } 49 | 50 | function strip (dependency) { 51 | return dependency.replace('@tempest/', '').trim() 52 | } 53 | 54 | function isTempestPackage (package) { 55 | return package.indexOf('@tempest') === 0 56 | } -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "2.0.0-beta.24", 3 | "version": "independent" 4 | } 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tempest", 3 | "version": "0.0.0", 4 | "description": "This is a monorepo for the Tempest stream library", 5 | "devDependencies": { 6 | "boxcutter": "^1.2.0", 7 | "commitizen": "^2.8.2", 8 | "cz-lerna-changelog": "^0.2.3", 9 | "ejs": "^2.5.1", 10 | "ghooks": "^1.3.2", 11 | "lerna": "^2.0.0-beta.24", 12 | "lerna-semantic-release": "^4.0.2", 13 | "rimraf": "^2.5.3", 14 | "symlink-or-copy": "^1.1.3", 15 | "tslint": "^3.13.0", 16 | "typescript": "^1.8.10", 17 | "validate-commit-msg": "^2.6.1" 18 | }, 19 | "scripts": { 20 | "clean": "lerna clean --yes && rimraf packages/**/*.log packages/**/*.log.* && rimraf *.log && rimraf node_modules", 21 | "scripts:run": "node _scripts/run-all-packages.js", 22 | "scripts:update-deps": "node _scripts/update-dependencies.js", 23 | "scripts:new-package": "node _scripts/new-package.js", 24 | "scripts:symlink": "node _scripts/symlink-all-packages.js", 25 | "postinstall": "lerna exec -- npm install && lerna --scope @tempest/core exec -- npm run build && npm run scripts:symlink", 26 | "lint": "lerna run lint", 27 | "build": "npm run scripts:symlink && npm run scripts:run build", 28 | "test": "lerna run test", 29 | "commit": "git cz", 30 | "release:pre": "lerna-semantic-release pre", 31 | "release:perform": "lerna-semantic-release perform", 32 | "release:post": "npm run build && git add . && git commit -m 'chore(release): build dist/' && lerna-semantic-release post", 33 | "release": "npm run release:pre && npm run release:perform && npm run release:post" 34 | }, 35 | "config": { 36 | "commitizen": { 37 | "path": "./node_modules/cz-lerna-changelog" 38 | }, 39 | "ghooks": { 40 | "commit-msg": "node ./node_modules/.bin/validate-commit-msg" 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /packages/combine/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **combine:** use local getSource instead of one from core ([4d44383](https://github.com/TylorS/tempest/commit/4d44383)) 8 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 9 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 10 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 11 | 12 | 13 | ### Features 14 | 15 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /packages/combine/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/combine", 3 | "version": "1.1.2", 4 | "description": "combine operator for tempest", 5 | "main": "dist/tempest-combine.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-combine.js -o dist/tempest-combine.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/combine/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-combine.js', 6 | format: 'umd', 7 | moduleName: 'tempestCombine', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/combine/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { combine } from '../src/index' 6 | 7 | describe('@tempest/combine', () => { 8 | it('should combine multiple streams into an array of values', (done) => { 9 | const stream = combine([ 10 | Stream.of(1), 11 | Stream.of(1, 2, 3), 12 | Stream.of(4) 13 | ]) 14 | 15 | const expected = [ 16 | [1, 3, 4] 17 | ] 18 | 19 | stream.subscribe(([x, y, z]) => { 20 | const [a, b, c] = expected.shift() 21 | assert(x === a) 22 | assert(y === b) 23 | assert(z === c) 24 | }, done, () => done()) 25 | }) 26 | }) -------------------------------------------------------------------------------- /packages/combine/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/combine/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/combine", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/core/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 0.3.1 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **core:** better typings for curry ([394eaaf](https://github.com/TylorS/tempest/commit/394eaaf)) 8 | * **core:** export externally used classes ([17d98a0](https://github.com/TylorS/tempest/commit/17d98a0)) 9 | * **core:** fix IndexSink ([2dbc6ee](https://github.com/TylorS/tempest/commit/2dbc6ee)) 10 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 11 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 12 | 13 | 14 | ### Features 15 | 16 | * **core:** implement curry functions for operators to use ([bd3292a](https://github.com/TylorS/tempest/commit/bd3292a)) 17 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /packages/core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/core", 3 | "version": "0.3.1", 4 | "description": "The core of the Tempest Stream Library", 5 | "main": "dist/tempest-core.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-core.js -o dist/tempest-core.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "keywords": [ 20 | "tempest", 21 | "streams", 22 | "reactive", 23 | "Cycle", 24 | "Cycle.js" 25 | ], 26 | "author": "Tylor Steinberger ", 27 | "license": "MIT", 28 | "dependencies": { 29 | "symbol-observable": "^1.0.1" 30 | }, 31 | "devDependencies": { 32 | "espower-typescript": "^5.0.1", 33 | "mkdirp": "^0.5.1", 34 | "mocha": "^2.5.3", 35 | "power-assert": "^1.4.1", 36 | "rimraf": "^2.5.3", 37 | "rollup": "^0.34.1", 38 | "rollup-plugin-buble": "^0.12.1", 39 | "rollup-plugin-node-resolve": "^1.7.1", 40 | "ts-node": "^0.9.3", 41 | "tslint": "^3.13.0", 42 | "typings": "^1.3.1", 43 | "uglify-js": "^2.7.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/core/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | import nodeResolve from 'rollup-plugin-node-resolve' 3 | 4 | export default { 5 | entry: 'lib/index.js', 6 | dest: 'dist/tempest-core.js', 7 | format: 'umd', 8 | moduleName: 'tempestCore', 9 | sourceMap: true, 10 | plugins: [ 11 | buble(), 12 | nodeResolve({ 13 | jsnext: true, 14 | main: true, 15 | browser: true 16 | }) 17 | ] 18 | } -------------------------------------------------------------------------------- /packages/core/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './interfaces' 2 | export { Stream } from './Stream' 3 | export { defaultScheduler } from './scheduler/defaultScheduler' 4 | export { PropagateTask } from './scheduler/PropagateTask' 5 | export { runSource, withScheduler, withDefaultScheduler } from './runSource' 6 | export { getSource } from './util/getSource' 7 | export { BasicSubscription } from './util/BasicSubscription' 8 | export { SubscriberSink } from './util/SubscriberSink' 9 | export { IndexSink, IndexedValue } from './util/IndexSink' 10 | export { Multicast } from './multicast/Multicast' 11 | export * from './util/curry' -------------------------------------------------------------------------------- /packages/core/src/interfaces.ts: -------------------------------------------------------------------------------- 1 | export interface Subscribable { 2 | source: Source 3 | subscribe(nextOrObserver?: Subscriber | ((x: T) => any), 4 | error?: (error: Error) => any, 5 | complete?: (x?: T) => any): Subscription 6 | } 7 | 8 | export interface Source { 9 | run (sink: Sink, scheduler: Scheduler): Disposable 10 | } 11 | 12 | export interface Sink { 13 | event (time: number, value: T): void 14 | end (time: number, value?: T): void 15 | error (time: number, err: Error): void 16 | } 17 | 18 | export interface Scheduler { 19 | now(): number 20 | asap(task: Task): ScheduledTask 21 | delay(delayTime: number, task: Task): ScheduledTask 22 | periodic(period: number, task: Task): ScheduledTask 23 | schedule(delay: number, period: number, task: Task): ScheduledTask 24 | cancel(task: ScheduledTask): void 25 | cancelAll(predicate: (task: ScheduledTask) => boolean): void 26 | } 27 | 28 | export interface Timeline { 29 | nextArrival (): number 30 | isEmpty (): boolean 31 | add (task: T): void 32 | remove (task: T): boolean 33 | removeAll (f: (task: T) => boolean): void 34 | runTasks (time: number, runTask: (task: T) => any): void 35 | } 36 | 37 | export interface Timeslot { 38 | time: number 39 | events: T[] 40 | } 41 | 42 | export interface Timer { 43 | now(): number, 44 | setTimer(fn: () => any, delayTime: number): T | number 45 | clearTimer(task: T): any 46 | } 47 | 48 | export interface Task { 49 | run(time: number): void 50 | error(time: number, e: Error): void 51 | dispose(): void 52 | } 53 | 54 | export interface ScheduledTask { 55 | task: Task 56 | run(): void 57 | error(err: Error): void 58 | dispose(): void 59 | } 60 | 61 | export interface Disposable { 62 | dispose(): void | Promise 63 | } 64 | 65 | export interface Subscriber { 66 | next(value: A): void; 67 | error(err: Error): void; 68 | complete(value?: A): void; 69 | } 70 | 71 | export interface Subscription { 72 | unsubscribe(): void; 73 | } -------------------------------------------------------------------------------- /packages/core/src/multicast/MulticastDisposable.ts: -------------------------------------------------------------------------------- 1 | import { Disposable, Sink, Scheduler } from '../interfaces' 2 | 3 | import { Multicast } from './Multicast' 4 | import { MulticastTask } from './MulticastTask' 5 | 6 | export class MulticastDisposable implements Disposable { 7 | private source: Multicast 8 | private sink: Sink 9 | private scheduler: Scheduler 10 | private disposed: boolean 11 | constructor (source: Multicast, sink: Sink, scheduler: Scheduler) { 12 | this.source = source 13 | this.sink = sink 14 | this.scheduler = scheduler 15 | this.disposed = false 16 | } 17 | 18 | dispose () { 19 | if (this.disposed) return 20 | this.disposed = true 21 | 22 | const source = this.source 23 | 24 | const remaining = source._remove(this.sink) 25 | if (remaining === 0) { 26 | const task = MulticastTask.create(() => source._dispose()) 27 | source._stopId = this.scheduler.asap(task) 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /packages/core/src/multicast/MulticastTask.ts: -------------------------------------------------------------------------------- 1 | import { Task } from '../interfaces' 2 | 3 | export class MulticastTask implements Task { 4 | private _run: () => any 5 | private active: boolean 6 | constructor (run: () => any) { 7 | this._run = run 8 | this.active = true 9 | } 10 | 11 | static create (run: () => any) { 12 | return new MulticastTask(run) 13 | } 14 | 15 | run (time: number): void { 16 | if (!this.active) return 17 | this._run() 18 | } 19 | 20 | error (time: number, err: Error): void { 21 | return void 0 22 | } 23 | 24 | dispose (): void { 25 | this.active = false 26 | } 27 | } -------------------------------------------------------------------------------- /packages/core/src/scheduler/ClockTimer.ts: -------------------------------------------------------------------------------- 1 | import { Timer, Task } from '../interfaces' 2 | import { defer } from '../util/task' 3 | 4 | export class ClockTimer implements Timer { 5 | now (): number { 6 | return Date.now() 7 | } 8 | 9 | setTimer (fn: () => any, delayTime: number): Asap | any { 10 | return delayTime <= 0 11 | ? runAsTask(fn) 12 | : setTimeout(fn, delayTime) 13 | } 14 | 15 | clearTimer (task: Asap | any ) { 16 | return task instanceof Asap 17 | ? task.dispose() 18 | : clearTimeout(task) 19 | } 20 | } 21 | 22 | export class Asap implements Task { 23 | private f: () => any 24 | private active: boolean 25 | constructor (f: () => any) { 26 | this.f = f 27 | this.active = true 28 | } 29 | 30 | run (time: number): void { 31 | if (this.active) this.f() 32 | } 33 | 34 | error (time: number, e: Error) { 35 | throw e 36 | } 37 | 38 | dispose (): void { 39 | this.active = false 40 | } 41 | } 42 | 43 | function runAsTask (f: () => any) { 44 | const task = new Asap(f) 45 | defer(task) 46 | return task 47 | } -------------------------------------------------------------------------------- /packages/core/src/scheduler/PredeterminedTask.ts: -------------------------------------------------------------------------------- 1 | import { Task, ScheduledTask, Scheduler } from '../interfaces' 2 | 3 | export class PredeterminedTask implements ScheduledTask { 4 | public task: Task 5 | public time: number 6 | public period: number 7 | private scheduler: Scheduler 8 | public active: boolean 9 | constructor (delay: number, period: number, task: Task, scheduler: Scheduler) { 10 | this.time = delay 11 | this.period = period 12 | this.task = task 13 | this.scheduler = scheduler 14 | this.active = true 15 | } 16 | 17 | run (): void { 18 | this.task.run(this.time) 19 | } 20 | 21 | error (err: Error): void { 22 | this.task.error(this.time, err) 23 | } 24 | 25 | dispose (): void { 26 | this.scheduler.cancel(this) 27 | return this.task.dispose() 28 | } 29 | } -------------------------------------------------------------------------------- /packages/core/src/scheduler/PropagateTask.ts: -------------------------------------------------------------------------------- 1 | import { Task, Sink } from '../interfaces' 2 | import { fatalError } from '../util/fatalError' 3 | 4 | export type RunFn = (time: number, value: T, sink: Sink) => void 5 | 6 | export class PropagateTask implements Task { 7 | private _run: RunFn 8 | private value: T 9 | private sink: Sink 10 | private active: boolean 11 | constructor (run: RunFn, value: T, sink: Sink) { 12 | this._run = run 13 | this.value = value 14 | this.sink = sink 15 | this.active = true 16 | } 17 | 18 | static event (value: T, sink: Sink): PropagateTask { 19 | return new PropagateTask(event, value, sink) 20 | } 21 | 22 | static error (err: Error, sink: Sink): PropagateTask { 23 | return new PropagateTask(error, err, sink) 24 | } 25 | 26 | static end (value: T, sink: Sink): PropagateTask { 27 | return new PropagateTask(end, value, sink) 28 | } 29 | 30 | run (time: number): void { 31 | if (!this.active) return 32 | 33 | this._run(time, this.value, this.sink) 34 | } 35 | 36 | error (time: number, err: Error): void { 37 | if (!this.active) fatalError(err) 38 | this.active = false 39 | this.sink.error(time, err) 40 | } 41 | 42 | dispose (): void { 43 | this.active = false 44 | } 45 | } 46 | 47 | function event (time: number, value: T, sink: Sink): void { 48 | sink.event(time, value) 49 | } 50 | 51 | function error (time: number, err: Error, sink: Sink): void { 52 | sink.error(time, err) 53 | } 54 | 55 | function end (time: number, value: T, sink: Sink): void { 56 | sink.end(time, value) 57 | } -------------------------------------------------------------------------------- /packages/core/src/scheduler/defaultScheduler.ts: -------------------------------------------------------------------------------- 1 | import { TaskScheduler } from './Scheduler' 2 | import { ClockTimer } from './ClockTimer' 3 | import { BinaryTimeline } from './BinaryTimeline' 4 | 5 | export const defaultScheduler = new TaskScheduler(new ClockTimer(), new BinaryTimeline()) 6 | -------------------------------------------------------------------------------- /packages/core/src/source/fromArray.ts: -------------------------------------------------------------------------------- 1 | import { Source, Sink, Scheduler } from '../interfaces' 2 | import { PropagateTask } from '../scheduler/PropagateTask' 3 | 4 | export class FromArraySource implements Source { 5 | constructor (private array: T[]) {} 6 | 7 | run (sink: Sink, scheduler: Scheduler) { 8 | const task = scheduler.asap(new PropagateTask(runArrayTask(this.array, scheduler), void 0, sink)) 9 | return { dispose: () => task.dispose() } 10 | } 11 | } 12 | 13 | function runArrayTask (array: T[], scheduler: Scheduler) { 14 | return function arrayTask (time: number, value: T, sink: Sink) { 15 | array.forEach((x: T) => sink.event(scheduler.now(), x)) 16 | sink.end(scheduler.now(), void 0) 17 | } 18 | } -------------------------------------------------------------------------------- /packages/core/src/source/fromObservable.ts: -------------------------------------------------------------------------------- 1 | import { Subscribable, Source, Sink, Scheduler } from '../interfaces' 2 | 3 | export class FromObservableSource implements Source { 4 | constructor (private observable: Subscribable) { 5 | } 6 | 7 | run (sink: Sink, scheduler: Scheduler) { 8 | const next = (x: T) => sink.event(scheduler.now(), x) 9 | const error = (e: Error) => sink.error(scheduler.now(), e) 10 | const complete = (x?: T) => sink.end(scheduler.now(), x) 11 | const subscription = this.observable.subscribe({ next, error, complete }) 12 | 13 | return { dispose: () => subscription.unsubscribe() } 14 | } 15 | } -------------------------------------------------------------------------------- /packages/core/src/util/BasicSubscription.ts: -------------------------------------------------------------------------------- 1 | import { Subscription, Disposable, Source, Sink } from '../interfaces' 2 | import { defaultScheduler } from '../scheduler/defaultScheduler' 3 | 4 | export class BasicSubscription implements Subscription { 5 | private disposable: Disposable 6 | constructor (private source: Source, private sink: Sink) { 7 | this.disposable = source.run(sink, defaultScheduler) 8 | } 9 | 10 | static create (source: Source, sink: Sink) { 11 | return new BasicSubscription(source, sink) 12 | } 13 | 14 | unsubscribe (): void { 15 | this.disposable.dispose() 16 | } 17 | } -------------------------------------------------------------------------------- /packages/core/src/util/IndexSink.ts: -------------------------------------------------------------------------------- 1 | import { Sink } from '../interfaces' 2 | 3 | export interface IndexedValue { 4 | index: number, 5 | value: T 6 | } 7 | 8 | export class IndexSink implements Sink { 9 | private active: boolean = true 10 | private value: T = void 0 11 | constructor (private index: number, private sink: Sink>) {} 12 | 13 | event (time: number, value: T) { 14 | if (!this.active) return 15 | 16 | this.value = value 17 | this.sink.event(time, { index: this.index, value: this.value }) 18 | } 19 | 20 | error (time: number, err: Error) { 21 | this.sink.error(time, err) 22 | } 23 | 24 | end (time: number, value?: T) { 25 | if (!this.active) return 26 | this.active = false 27 | this.sink.end(time, { index: this.index, value }) 28 | } 29 | } -------------------------------------------------------------------------------- /packages/core/src/util/SubscriberSink.ts: -------------------------------------------------------------------------------- 1 | import { Sink } from '../interfaces' 2 | 3 | export class SubscriberSink implements Sink { 4 | constructor (private _next: (x: T) => any, 5 | private _error: (e: Error) => any, 6 | private _complete: (x?: T) => any) {} 7 | 8 | static create (next: (x: T) => any, 9 | error: (e: Error) => any, 10 | complete: (x?: T) => any) { 11 | return new SubscriberSink(next, error, complete) 12 | } 13 | 14 | event (t: number, x: T) { 15 | const { _next } = this 16 | _next(x) 17 | } 18 | 19 | error (t: number, e: Error) { 20 | const { _error } = this 21 | _error(e) 22 | } 23 | 24 | end (t: number, x?: T) { 25 | const { _complete } = this 26 | _complete(x) 27 | } 28 | } -------------------------------------------------------------------------------- /packages/core/src/util/fatalError.ts: -------------------------------------------------------------------------------- 1 | export function fatalError (err: Error): void { 2 | setTimeout(() => { throw err }, 0) 3 | } -------------------------------------------------------------------------------- /packages/core/src/util/getSource.ts: -------------------------------------------------------------------------------- 1 | import { Source } from '../interfaces' 2 | import { Stream } from '../Stream' 3 | import { Multicast } from '../multicast/Multicast' 4 | 5 | export function getSource (stream: Stream): Source { 6 | return stream.source instanceof Multicast 7 | ? (stream.source as Multicast).source 8 | : stream.source 9 | } -------------------------------------------------------------------------------- /packages/core/src/util/task.ts: -------------------------------------------------------------------------------- 1 | import { Task, ScheduledTask } from '../interfaces' 2 | 3 | export function defer (task: Task): Promise { 4 | return Promise.resolve(task).then(runTask) 5 | } 6 | 7 | export function runTask (task: Task): void { 8 | try { 9 | return task.run(Date.now()) 10 | } catch (e) { 11 | return task.error(Date.now(), e) 12 | } 13 | } 14 | 15 | export function runScheduledTask (task: ScheduledTask): void { 16 | try { 17 | task.run() 18 | } catch (e) { 19 | task.error(e) 20 | } 21 | } -------------------------------------------------------------------------------- /packages/core/test/helpers/FakeSink.ts: -------------------------------------------------------------------------------- 1 | import { Sink } from '../../src/interfaces' 2 | 3 | export interface SinkAssertions { 4 | event?: (x: T) => any 5 | error?: (e: Error) => any 6 | end?: (x: T) => any 7 | } 8 | 9 | export class FakeSink implements Sink { 10 | constructor (private assertions?: SinkAssertions) {} 11 | 12 | static create (assertions?: SinkAssertions) { 13 | return new FakeSink(assertions) 14 | } 15 | 16 | event (t: number, x: T) { 17 | if (this.assertions && typeof this.assertions.event === 'function') 18 | this.assertions.event(x) 19 | } 20 | 21 | error (t: number, e: Error) { 22 | if (this.assertions && typeof this.assertions.error === 'function') 23 | this.assertions.error(e) 24 | } 25 | 26 | end (t: number, x?: T) { 27 | if (this.assertions && typeof this.assertions.end === 'function') 28 | this.assertions.end(x) 29 | } 30 | } -------------------------------------------------------------------------------- /packages/core/test/helpers/FakeSource.ts: -------------------------------------------------------------------------------- 1 | import { Source, Sink, Scheduler } from '../../src/index' 2 | 3 | export interface SourceAssertions { 4 | run?: (sink: Sink, scheduler: Scheduler) => any 5 | dispose?: () => any 6 | } 7 | 8 | export class FakeSource implements Source { 9 | constructor (private assertions?: SourceAssertions) {} 10 | 11 | static create (assertions?: SourceAssertions) { 12 | return new FakeSource(assertions) 13 | } 14 | 15 | run (sink: Sink, scheduler: Scheduler) { 16 | if (this.assertions && typeof this.assertions.run === 'function') 17 | this.assertions.run(sink, scheduler) 18 | 19 | const _dispose = this.assertions && typeof this.assertions.dispose === 'function' 20 | ? this.assertions.dispose 21 | : Function.prototype 22 | return { 23 | dispose () { 24 | _dispose() 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /packages/core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/core/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/core", 3 | "dependencies": {}, 4 | "globalDevDependencies": { 5 | "empower": "registry:dt/empower#0.0.0+20160317120654", 6 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 7 | "node": "registry:dt/node#6.0.0+20160709114037", 8 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 9 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/create/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/create/dist/tempest-create.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tempest/core')) : 3 | typeof define === 'function' && define.amd ? define(['exports', '@tempest/core'], factory) : 4 | (factory((global.tempestCreate = global.tempestCreate || {}),global.tempestCore)); 5 | }(this, function (exports,_tempest_core) { 'use strict'; 6 | 7 | function create(subscriber) { 8 | return new _tempest_core.Stream(new Create(subscriber)); 9 | } 10 | var Create = function Create(_subscribe) { 11 | this._subscribe = _subscribe; 12 | }; 13 | Create.prototype.run = function run (sink, scheduler) { 14 | var subscribe = this._subscribe; 15 | var observer = new SinkObserver(sink, scheduler); 16 | var dispose = Promise.resolve(observer).then(subscribe); 17 | return { 18 | dispose: function dispose$1() { 19 | dispose.then(function (f) { 20 | if (typeof f === 'function') 21 | f(); 22 | }); 23 | } 24 | }; 25 | }; 26 | var SinkObserver = function SinkObserver(sink, scheduler) { 27 | this.sink = sink; 28 | this.scheduler = scheduler; 29 | }; 30 | SinkObserver.prototype.next = function next (value) { 31 | this.sink.event(this.scheduler.now(), value); 32 | }; 33 | SinkObserver.prototype.error = function error (err) { 34 | this.sink.error(this.scheduler.now(), err); 35 | }; 36 | SinkObserver.prototype.complete = function complete (value) { 37 | this.sink.end(this.scheduler.now(), value); 38 | }; 39 | 40 | exports.create = create; 41 | exports.Create = Create; 42 | 43 | Object.defineProperty(exports, '__esModule', { value: true }); 44 | 45 | })); 46 | //# sourceMappingURL=tempest-create.js.map 47 | -------------------------------------------------------------------------------- /packages/create/dist/tempest-create.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestCreate=global.tempestCreate||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";function create(subscriber){return new _tempest_core.Stream(new Create(subscriber))}var Create=function Create(_subscribe){this._subscribe=_subscribe};Create.prototype.run=function run(sink,scheduler){var subscribe=this._subscribe;var observer=new SinkObserver(sink,scheduler);var dispose=Promise.resolve(observer).then(subscribe);return{dispose:function dispose$1(){dispose.then(function(f){if(typeof f==="function")f()})}}};var SinkObserver=function SinkObserver(sink,scheduler){this.sink=sink;this.scheduler=scheduler};SinkObserver.prototype.next=function next(value){this.sink.event(this.scheduler.now(),value)};SinkObserver.prototype.error=function error(err){this.sink.error(this.scheduler.now(),err)};SinkObserver.prototype.complete=function complete(value){this.sink.end(this.scheduler.now(),value)};exports.create=create;exports.Create=Create;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/create/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/create", 3 | "version": "1.1.2", 4 | "description": "create factory for tempest", 5 | "main": "dist/tempest-create.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-create.js -o dist/tempest-create.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/create/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-create.js', 6 | format: 'umd', 7 | moduleName: 'tempestCreate', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/create/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Disposable, Scheduler, Subscriber } from '@tempest/core' 2 | 3 | export type SubscriberFn = (observer: Subscriber) => (() => any) | void 4 | 5 | export function create (subscriber: SubscriberFn): Stream { 6 | return new Stream(new Create(subscriber)) 7 | } 8 | 9 | export class Create implements Source { 10 | constructor (private _subscribe: SubscriberFn) {} 11 | 12 | run (sink: Sink, scheduler: Scheduler): Disposable { 13 | const subscribe = this._subscribe 14 | const observer = new SinkObserver(sink, scheduler) 15 | const dispose = Promise.resolve(observer).then(subscribe) 16 | return { 17 | dispose () { 18 | dispose.then((f: () => any | void ) => { 19 | if (typeof f === 'function') f() 20 | }) 21 | } 22 | } 23 | } 24 | } 25 | 26 | class SinkObserver implements Subscriber { 27 | constructor (private sink: Sink, private scheduler: Scheduler) {} 28 | 29 | next (value: T) { 30 | this.sink.event(this.scheduler.now(), value) 31 | } 32 | 33 | error (err: Error) { 34 | this.sink.error(this.scheduler.now(), err) 35 | } 36 | 37 | complete (value?: T) { 38 | this.sink.end(this.scheduler.now(), value) 39 | } 40 | } -------------------------------------------------------------------------------- /packages/create/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { create } from '../src/index' 6 | 7 | describe('@tempest/create', () => { 8 | it ('should create a new stream with a subscriber fn', (done) => { 9 | const stream: Stream = create((observer) => { 10 | observer.next(1) 11 | observer.next(2) 12 | observer.next(3) 13 | observer.complete() 14 | return done 15 | }) 16 | 17 | const expected = [1, 2, 3] 18 | 19 | const sub = stream.subscribe((x) => { 20 | assert(x === expected.shift()) 21 | }, done, () => { 22 | assert(expected.length === 0) 23 | sub.unsubscribe() 24 | }) 25 | }) 26 | }) -------------------------------------------------------------------------------- /packages/create/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/create/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/create", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/debug/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # 1.2.0 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **debug:** curry exported function ([e8be8f9](https://github.com/TylorS/tempest/commit/e8be8f9)) 15 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /packages/debug/dist/tempest-debug.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestDebug=global.tempestDebug||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";var debug=function(infoOrSpy,stream){switch(arguments.length){case 1:return function(stream){return new _tempest_core.Stream(new Debug(infoOrSpy,stream.source))};case 2:return new _tempest_core.Stream(new Debug(infoOrSpy,stream.source));default:return debug}};var Debug=function Debug(infoOrSpy,source){this.infoOrSpy=infoOrSpy;this.source=source};Debug.prototype.run=function run(sink,scheduler){if(typeof this.infoOrSpy==="object"){if(typeof this.infoOrSpy.dispose==="function"){var disposeSpy=this.infoOrSpy.dispose;var disposable=this.source.run(new DebugSink(this.infoOrSpy,sink),scheduler);return{dispose:function dispose(){disposeSpy();return disposable.dispose()}}}}else{return this.source.run(new DebugSink(this.infoOrSpy,sink),scheduler)}};var DebugSink=function DebugSink(infoOrSpy,sink){this.infoOrSpy=infoOrSpy;this.sink=sink};DebugSink.prototype.event=function event(time,value){if(typeof this.infoOrSpy==="string"){console.log(this.infoOrSpy+":",value)}else if(typeof this.infoOrSpy==="object"){if(typeof this.infoOrSpy.next==="function"){this.infoOrSpy.next(value)}}this.sink.event(time,value)};DebugSink.prototype.error=function error(time,err){if(typeof this.infoOrSpy==="object"){if(typeof this.infoOrSpy.error==="function"){this.infoOrSpy.error(err)}}this.sink.error(time,err)};DebugSink.prototype.end=function end(time,value){if(typeof this.infoOrSpy==="string"){console.log(this.infoOrSpy+": ending")}else if(typeof this.infoOrSpy==="object"){if(typeof this.infoOrSpy.complete==="function"){this.infoOrSpy.complete(value)}}this.sink.end(time,value)};exports.debug=debug;exports.Debug=Debug;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/debug/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-debug.js', 6 | format: 'umd', 7 | moduleName: 'tempestDebug', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/debug/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/debug/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/debug", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654", 9 | "sinon": "registry:dt/sinon#1.16.0+20160517064723" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/drop/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # 1.2.0 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **drop:** curry external api ([51f5579](https://github.com/TylorS/tempest/commit/51f5579)) 15 | * **drop:** implement drop operator ([039735c](https://github.com/TylorS/tempest/commit/039735c)) 16 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /packages/drop/dist/tempest-drop.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tempest/core')) : 3 | typeof define === 'function' && define.amd ? define(['exports', '@tempest/core'], factory) : 4 | (factory((global.tempestDrop = global.tempestDrop || {}),global.tempestCore)); 5 | }(this, function (exports,_tempest_core) { 'use strict'; 6 | 7 | var drop = function (amount, stream) { 8 | switch (arguments.length) { 9 | case 1: return function (stream) { return new _tempest_core.Stream(new Drop(amount, stream.source)); }; 10 | case 2: return new _tempest_core.Stream(new Drop(amount, stream.source)); 11 | default: return drop; 12 | } 13 | }; 14 | var Drop = function Drop(amount, source) { 15 | this.amount = amount; 16 | this.source = source; 17 | }; 18 | Drop.prototype.run = function run (sink, scheduler) { 19 | return new DropSink(this.amount, sink, this.source, scheduler); 20 | }; 21 | var DropSink = function DropSink(amount, sink, source, scheduler) { 22 | this.amount = amount; 23 | this.sink = sink; 24 | this.disposable = source.run(this, scheduler); 25 | }; 26 | DropSink.prototype.event = function event (time, value) { 27 | if (--this.amount < 0) { 28 | this.sink.event(time, value); 29 | } 30 | }; 31 | DropSink.prototype.error = function error (time, err) { 32 | this.sink.error(time, err); 33 | }; 34 | DropSink.prototype.end = function end (time, value) { 35 | this.sink.end(time, value); 36 | }; 37 | DropSink.prototype.dispose = function dispose () { 38 | return this.disposable.dispose(); 39 | }; 40 | 41 | exports.drop = drop; 42 | 43 | Object.defineProperty(exports, '__esModule', { value: true }); 44 | 45 | })); 46 | //# sourceMappingURL=tempest-drop.js.map 47 | -------------------------------------------------------------------------------- /packages/drop/dist/tempest-drop.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestDrop=global.tempestDrop||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";var drop=function(amount,stream){switch(arguments.length){case 1:return function(stream){return new _tempest_core.Stream(new Drop(amount,stream.source))};case 2:return new _tempest_core.Stream(new Drop(amount,stream.source));default:return drop}};var Drop=function Drop(amount,source){this.amount=amount;this.source=source};Drop.prototype.run=function run(sink,scheduler){return new DropSink(this.amount,sink,this.source,scheduler)};var DropSink=function DropSink(amount,sink,source,scheduler){this.amount=amount;this.sink=sink;this.disposable=source.run(this,scheduler)};DropSink.prototype.event=function event(time,value){if(--this.amount<0){this.sink.event(time,value)}};DropSink.prototype.error=function error(time,err){this.sink.error(time,err)};DropSink.prototype.end=function end(time,value){this.sink.end(time,value)};DropSink.prototype.dispose=function dispose(){return this.disposable.dispose()};exports.drop=drop;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/drop/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/drop", 3 | "version": "1.2.0", 4 | "description": "drop operator for tempest", 5 | "main": "dist/tempest-drop.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-drop.js -o dist/tempest-drop.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/drop/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-drop.js', 6 | format: 'umd', 7 | moduleName: 'tempestDrop', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/drop/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Scheduler, Disposable} from '@tempest/core' 2 | 3 | export interface DropCurried { 4 | (): (amount: number, stream: Stream) => Stream 5 | (amount: number): (stream: Stream) => Stream 6 | (amount: number, stream: Stream): Stream 7 | } 8 | 9 | export const drop: DropCurried = function (amount: number , stream: Stream): 10 | ((amount: number, stream: Stream) => Stream) | 11 | ((stream: Stream) => Stream) | 12 | Stream { 13 | switch (arguments.length) { 14 | case 1: return function (stream: Stream) { return new Stream(new Drop(amount, stream.source)) } 15 | case 2: return new Stream(new Drop(amount, stream.source)) 16 | default: return drop 17 | } 18 | } 19 | 20 | class Drop implements Source { 21 | constructor (private amount: number, private source: Source) {} 22 | 23 | run (sink: Sink, scheduler: Scheduler): Disposable { 24 | return new DropSink(this.amount, sink, this.source, scheduler) 25 | } 26 | } 27 | 28 | class DropSink implements Sink, Disposable { 29 | private disposable: Disposable 30 | constructor (private amount: number, private sink: Sink, 31 | source: Source, scheduler: Scheduler) { 32 | this.disposable = source.run(this, scheduler) 33 | } 34 | 35 | event (time: number, value: T) { 36 | if (--this.amount < 0) { 37 | this.sink.event(time, value) 38 | } 39 | } 40 | 41 | error (time: number, err: Error) { 42 | this.sink.error(time, err) 43 | } 44 | 45 | end (time: number, value?: T) { 46 | this.sink.end(time, value) 47 | } 48 | 49 | dispose () { 50 | return this.disposable.dispose() 51 | } 52 | } -------------------------------------------------------------------------------- /packages/drop/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { drop } from '../src/index' 6 | 7 | describe('@tempest/drop', () => { 8 | it ('should drop first n events', (done) => { 9 | const stream = drop(1, Stream.of(1, 2, 3)) 10 | const expected = [2, 3] 11 | 12 | stream.subscribe((x: number) => { 13 | assert(x === expected.shift()) 14 | }, done, () => done()) 15 | }) 16 | 17 | it ('should be curried', (done) => { 18 | const dropOne = drop(1) 19 | const stream = dropOne(Stream.of(1, 2, 3)) 20 | const expected = [2, 3] 21 | 22 | stream.subscribe((x: number) => { 23 | assert(x === expected.shift()) 24 | }, done, () => done()) 25 | }) 26 | }) -------------------------------------------------------------------------------- /packages/drop/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/drop/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/drop", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/empty/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/empty/dist/tempest-empty.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tempest/core')) : 3 | typeof define === 'function' && define.amd ? define(['exports', '@tempest/core'], factory) : 4 | (factory((global.tempestEmpty = global.tempestEmpty || {}),global.tempestCore)); 5 | }(this, function (exports,_tempest_core) { 'use strict'; 6 | 7 | function empty() { 8 | return new _tempest_core.Stream(new Empty()); 9 | } 10 | var Empty = function Empty () {}; 11 | 12 | Empty.prototype.run = function run (sink, scheduler) { 13 | var task = scheduler.asap(_tempest_core.PropagateTask.end(void 0, sink)); 14 | return { 15 | dispose: function dispose() { 16 | scheduler.cancel(task); 17 | } 18 | }; 19 | }; 20 | 21 | exports.empty = empty; 22 | exports.Empty = Empty; 23 | 24 | Object.defineProperty(exports, '__esModule', { value: true }); 25 | 26 | })); 27 | //# sourceMappingURL=tempest-empty.js.map 28 | -------------------------------------------------------------------------------- /packages/empty/dist/tempest-empty.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":null,"sources":["../lib/index.js"],"sourcesContent":["import { Stream, PropagateTask } from '@tempest/core';\nexport function empty() {\n return new Stream(new Empty());\n}\nexport class Empty {\n run(sink, scheduler) {\n const task = scheduler.asap(PropagateTask.end(void 0, sink));\n return {\n dispose() {\n scheduler.cancel(task);\n }\n };\n }\n}\n//# sourceMappingURL=index.js.map"],"names":["Stream","PropagateTask"],"mappings":";;;;;;IACO,SAAS,KAAK,GAAG;QACpB,OAAO,IAAIA,oBAAM,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;KAClC;AACD,AAAO,IAAA,IAAM,KAAK,GAAC;;AAAA,IAAA,gBACf,GAAG,iBAAC,IAAI,EAAE,SAAS,EAAE;QACrB,IAAU,IAAI,GAAG,SAAS,CAAC,IAAI,CAACC,2BAAa,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QACjE,OAAW;YACP,OAAW,kBAAA,GAAG;gBACV,SAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAC1B;SACJ,CAAC;AACV,IAAA,CAAK,CAAA;;;;;;;"} -------------------------------------------------------------------------------- /packages/empty/dist/tempest-empty.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestEmpty=global.tempestEmpty||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";function empty(){return new _tempest_core.Stream(new Empty)}var Empty=function Empty(){};Empty.prototype.run=function run(sink,scheduler){var task=scheduler.asap(_tempest_core.PropagateTask.end(void 0,sink));return{dispose:function dispose(){scheduler.cancel(task)}}};exports.empty=empty;exports.Empty=Empty;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/empty/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/empty", 3 | "version": "1.1.2", 4 | "description": "empty factory for tempest", 5 | "main": "dist/tempest-empty.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-empty.js -o dist/tempest-empty.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/empty/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-empty.js', 6 | format: 'umd', 7 | moduleName: 'tempestEmpty', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/empty/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Disposable, Scheduler, PropagateTask } from '@tempest/core' 2 | 3 | export function empty (): Stream { 4 | return new Stream(new Empty()) 5 | } 6 | 7 | export class Empty implements Source { 8 | 9 | run (sink: Sink, scheduler: Scheduler): Disposable { 10 | const task = scheduler.asap(PropagateTask.end(void 0, sink)) 11 | return { 12 | dispose () { 13 | scheduler.cancel(task) 14 | } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /packages/empty/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { empty } from '../src/index' 6 | 7 | describe('@tempest/empty', () => { 8 | it ('should create a stream that has already ended', (done) => { 9 | const stream: Stream = empty() 10 | assert(stream instanceof Stream) 11 | 12 | stream.subscribe(done, done, () => done()) 13 | }) 14 | }) -------------------------------------------------------------------------------- /packages/empty/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/empty/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/empty", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/endWhen/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # 1.2.0 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **endWhen:** curry external api ([41a5a34](https://github.com/TylorS/tempest/commit/41a5a34)) 15 | * **endWhen:** implement endWhen operator ([e57050d](https://github.com/TylorS/tempest/commit/e57050d)) 16 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /packages/endWhen/dist/tempest-endWhen.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tempest/core')) : 3 | typeof define === 'function' && define.amd ? define(['exports', '@tempest/core'], factory) : 4 | (factory((global.tempestEndWhen = global.tempestEndWhen || {}),global.tempestCore)); 5 | }(this, function (exports,_tempest_core) { 'use strict'; 6 | 7 | var endWhen = function (signal, stream) { 8 | switch (arguments.length) { 9 | case 1: return function (stream) { return new _tempest_core.Stream(new EndWhen(signal.source, stream.source)); }; 10 | case 2: return new _tempest_core.Stream(new EndWhen(signal.source, stream.source)); 11 | default: return endWhen; 12 | } 13 | }; 14 | var EndWhen = function EndWhen(signal, source) { 15 | this.signal = signal; 16 | this.source = source; 17 | }; 18 | EndWhen.prototype.run = function run (sink, scheduler) { 19 | var disposable = this.source.run(sink, scheduler); 20 | var signalDisposable = this.signal.run({ 21 | event: function (t, x) { 22 | sink.end(t, x); 23 | disposable.dispose(); 24 | signalDisposable.dispose(); 25 | }, 26 | error: function (t, e) { return sink.error(t, e); }, 27 | end: Function.prototype 28 | }, scheduler); 29 | return { 30 | dispose: function dispose() { 31 | disposable.dispose(); 32 | signalDisposable.dispose(); 33 | } 34 | }; 35 | }; 36 | 37 | exports.endWhen = endWhen; 38 | exports.EndWhen = EndWhen; 39 | 40 | Object.defineProperty(exports, '__esModule', { value: true }); 41 | 42 | })); 43 | //# sourceMappingURL=tempest-endWhen.js.map 44 | -------------------------------------------------------------------------------- /packages/endWhen/dist/tempest-endWhen.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestEndWhen=global.tempestEndWhen||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";var endWhen=function(signal,stream){switch(arguments.length){case 1:return function(stream){return new _tempest_core.Stream(new EndWhen(signal.source,stream.source))};case 2:return new _tempest_core.Stream(new EndWhen(signal.source,stream.source));default:return endWhen}};var EndWhen=function EndWhen(signal,source){this.signal=signal;this.source=source};EndWhen.prototype.run=function run(sink,scheduler){var disposable=this.source.run(sink,scheduler);var signalDisposable=this.signal.run({event:function(t,x){sink.end(t,x);disposable.dispose();signalDisposable.dispose()},error:function(t,e){return sink.error(t,e)},end:Function.prototype},scheduler);return{dispose:function dispose(){disposable.dispose();signalDisposable.dispose()}}};exports.endWhen=endWhen;exports.EndWhen=EndWhen;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/endWhen/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/endWhen", 3 | "version": "1.2.0", 4 | "description": "endWhen operator for tempest", 5 | "main": "dist/tempest-endWhen.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-endWhen.js -o dist/tempest-endWhen.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/endWhen/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-endWhen.js', 6 | format: 'umd', 7 | moduleName: 'tempestEndWhen', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/endWhen/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Disposable, Scheduler } from '@tempest/core' 2 | 3 | export interface EndWhenCurried { 4 | (): (signal: Stream, stream: Stream) => Stream 5 | (signal: Stream): (stream: Stream) => Stream 6 | (signal: Stream, stream: Stream): Stream 7 | } 8 | 9 | export const endWhen: EndWhenCurried = function (signal: Stream, stream: Stream): 10 | Stream | 11 | ((stream: Stream) => Stream) | 12 | ((signal: Stream, stream: Stream) => Stream) 13 | { 14 | switch (arguments.length) { 15 | case 1: return function (stream: Stream) { return new Stream(new EndWhen(signal.source, stream.source)) } 16 | case 2: return new Stream(new EndWhen(signal.source, stream.source)) 17 | default: return endWhen 18 | } 19 | } 20 | 21 | export class EndWhen implements Source { 22 | constructor (private signal: Source, private source: Source) {} 23 | 24 | run (sink: Sink, scheduler: Scheduler): Disposable { 25 | const disposable = this.source.run(sink, scheduler) 26 | 27 | const signalDisposable = this.signal.run({ 28 | event: (t: number, x: T) => { 29 | sink.end(t, x) 30 | disposable.dispose() 31 | signalDisposable.dispose() 32 | }, 33 | error: (t: number, e: Error) => sink.error(t, e), 34 | end: Function.prototype as (t: number, x?: T) => any 35 | }, scheduler) 36 | 37 | return { 38 | dispose () { 39 | disposable.dispose() 40 | signalDisposable.dispose() 41 | } 42 | } 43 | } 44 | } 45 | 46 | class EndWhenSink implements Sink { 47 | constructor (private sink: Sink) {} 48 | 49 | event (time: number, value: T) { 50 | this.sink.event(time, value) 51 | } 52 | 53 | error (time: number, err: Error) { 54 | this.sink.error(time, err) 55 | } 56 | 57 | end (time: number, value?: T) { 58 | this.sink.end(time, value) 59 | } 60 | } -------------------------------------------------------------------------------- /packages/endWhen/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/endWhen/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/endWhen", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/filter/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # 1.2.0 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **filter:** curry external api ([74263f0](https://github.com/TylorS/tempest/commit/74263f0)) 15 | * **filter:** implement filter ([fdd5c3a](https://github.com/TylorS/tempest/commit/fdd5c3a)) 16 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /packages/filter/dist/tempest-filter.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tempest/core')) : 3 | typeof define === 'function' && define.amd ? define(['exports', '@tempest/core'], factory) : 4 | (factory((global.tempestFilter = global.tempestFilter || {}),global.tempestCore)); 5 | }(this, function (exports,_tempest_core) { 'use strict'; 6 | 7 | var filter = function (predicate, stream) { 8 | switch (arguments.length) { 9 | case 1: return function (stream) { return new _tempest_core.Stream(new Filter(predicate, stream.source)); }; 10 | case 2: return new _tempest_core.Stream(new Filter(predicate, stream.source)); 11 | default: return filter; 12 | } 13 | }; 14 | var Filter = function Filter(predicate, source) { 15 | this.predicate = predicate; 16 | this.source = source; 17 | }; 18 | Filter.prototype.run = function run (sink, scheduler) { 19 | return this.source.run(new FilterSink(this.predicate, sink), scheduler); 20 | }; 21 | var FilterSink = function FilterSink(predicate, sink) { 22 | this.predicate = predicate; 23 | this.sink = sink; 24 | }; 25 | FilterSink.prototype.event = function event (time, value) { 26 | if (this.predicate(value)) { 27 | this.sink.event(time, value); 28 | } 29 | }; 30 | FilterSink.prototype.error = function error (time, err) { 31 | this.sink.error(time, err); 32 | }; 33 | FilterSink.prototype.end = function end (time, value) { 34 | this.sink.end(time, value); 35 | }; 36 | 37 | exports.filter = filter; 38 | 39 | Object.defineProperty(exports, '__esModule', { value: true }); 40 | 41 | })); 42 | //# sourceMappingURL=tempest-filter.js.map 43 | -------------------------------------------------------------------------------- /packages/filter/dist/tempest-filter.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestFilter=global.tempestFilter||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";var filter=function(predicate,stream){switch(arguments.length){case 1:return function(stream){return new _tempest_core.Stream(new Filter(predicate,stream.source))};case 2:return new _tempest_core.Stream(new Filter(predicate,stream.source));default:return filter}};var Filter=function Filter(predicate,source){this.predicate=predicate;this.source=source};Filter.prototype.run=function run(sink,scheduler){return this.source.run(new FilterSink(this.predicate,sink),scheduler)};var FilterSink=function FilterSink(predicate,sink){this.predicate=predicate;this.sink=sink};FilterSink.prototype.event=function event(time,value){if(this.predicate(value)){this.sink.event(time,value)}};FilterSink.prototype.error=function error(time,err){this.sink.error(time,err)};FilterSink.prototype.end=function end(time,value){this.sink.end(time,value)};exports.filter=filter;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/filter/doc/assets/images/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TylorS/tempestjs/70ecc8fceed49c49b730c4eeda9775836c267a2f/packages/filter/doc/assets/images/icons.png -------------------------------------------------------------------------------- /packages/filter/doc/assets/images/icons@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TylorS/tempestjs/70ecc8fceed49c49b730c4eeda9775836c267a2f/packages/filter/doc/assets/images/icons@2x.png -------------------------------------------------------------------------------- /packages/filter/doc/assets/images/widgets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TylorS/tempestjs/70ecc8fceed49c49b730c4eeda9775836c267a2f/packages/filter/doc/assets/images/widgets.png -------------------------------------------------------------------------------- /packages/filter/doc/assets/images/widgets@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TylorS/tempestjs/70ecc8fceed49c49b730c4eeda9775836c267a2f/packages/filter/doc/assets/images/widgets@2x.png -------------------------------------------------------------------------------- /packages/filter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/filter", 3 | "version": "1.2.0", 4 | "description": "filter operator for tempest", 5 | "main": "dist/tempest-filter.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-filter.js -o dist/tempest-filter.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "filter", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/filter/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-filter.js', 6 | format: 'umd', 7 | moduleName: 'tempestFilter', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/filter/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Scheduler, Disposable } from '@tempest/core' 2 | 3 | export type PredicateFn = (x: T) => boolean 4 | 5 | export interface FilterCurried { 6 | (): FilterCurried 7 | (predicate: PredicateFn): (stream: Stream) => Stream 8 | (predicate: PredicateFn, stream: Stream): Stream 9 | } 10 | 11 | export const filter: FilterCurried = function (predicate: PredicateFn, stream: Stream): Stream | 12 | ((stream: Stream) => Stream) | 13 | ((predicate: PredicateFn, stream: Stream) => Stream) { 14 | switch (arguments.length) { 15 | case 1: return function (stream: Stream) { return new Stream(new Filter(predicate, stream.source)) } 16 | case 2: return new Stream(new Filter(predicate, stream.source)) 17 | default: return filter 18 | } 19 | } 20 | 21 | class Filter implements Source { 22 | constructor (public predicate: PredicateFn, public source: Source) {} 23 | 24 | run (sink: Sink, scheduler: Scheduler): Disposable { 25 | return this.source.run(new FilterSink(this.predicate, sink), scheduler) 26 | } 27 | } 28 | 29 | class FilterSink implements Sink { 30 | constructor (private predicate: PredicateFn, private sink: Sink) {} 31 | 32 | event (time: number, value: T) { 33 | if (this.predicate(value)) { 34 | this.sink.event(time, value) 35 | } 36 | } 37 | 38 | error (time: number, err: Error) { 39 | this.sink.error(time, err) 40 | } 41 | 42 | end (time: number, value?: T) { 43 | this.sink.end(time, value) 44 | } 45 | } -------------------------------------------------------------------------------- /packages/filter/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { filter } from '../src/index' 6 | 7 | describe('@tempest/filter', () => { 8 | it ('should filter event values', (done) => { 9 | const predicate = (x: number) => x > 2 10 | const stream = filter(predicate, Stream.of(1, 2, 3)) 11 | const expected = [3] 12 | 13 | stream.subscribe((x: number) => { 14 | assert(x === expected.shift()) 15 | }, done, () => done()) 16 | }) 17 | 18 | it ('should be curried', (done) => { 19 | const predicate = (x: number) => x > 2 20 | const greaterThan2 = filter(predicate) 21 | const stream: Stream = greaterThan2(Stream.of(1, 2, 3)) 22 | const expected = [3] 23 | 24 | stream.subscribe((x: number) => { 25 | assert(x === expected.shift()) 26 | }, done, () => done()) 27 | }) 28 | }) -------------------------------------------------------------------------------- /packages/filter/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/filter/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/take", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/flatten/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **flatten:** implement the flatten operator ([9a5d7f3](https://github.com/TylorS/tempest/commit/9a5d7f3)) 15 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /packages/flatten/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/flatten", 3 | "version": "1.1.2", 4 | "description": "flatten operator for tempest", 5 | "main": "dist/tempest-flatten.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-flatten.js -o dist/tempest-flatten.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/flatten/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-flatten.js', 6 | format: 'umd', 7 | moduleName: 'tempestFlatten', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/flatten/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/flatten/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/flatten", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/fold/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # 1.2.0 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **fold:** curry external api ([21acb41](https://github.com/TylorS/tempest/commit/21acb41)) 15 | * **fold:** implemenet fold operator ([42b8861](https://github.com/TylorS/tempest/commit/42b8861)) 16 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /packages/fold/dist/tempest-fold.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestFold=global.tempestFold||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";var fold=function(f,seed,stream){switch(arguments.length){case 1:return function(seed,stream){return fold(f,seed,stream)};case 2:return function(stream){return fold(f,seed,stream)};case 3:return new _tempest_core.Stream(new Fold(f,seed,stream.source));default:return fold}};var Fold=function Fold(f,seed,source){this.f=f;this.seed=seed;this.source=source};Fold.prototype.run=function run(sink,scheduler){scheduler.asap(_tempest_core.PropagateTask.event(this.seed,sink));return this.source.run(new FoldSink(this.f,this.seed,sink),scheduler)};var FoldSink=function FoldSink(f,seed,sink){this.f=f;this.seed=seed;this.sink=sink};FoldSink.prototype.event=function event(time,value){var ref=this;var f=ref.f;this.seed=f(this.seed,value);this.sink.event(time,this.seed)};FoldSink.prototype.error=function error(time,err){this.sink.error(time,err)};FoldSink.prototype.end=function end(time,value){this.sink.end(time,this.seed)};exports.fold=fold;exports.Fold=Fold;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/fold/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/fold", 3 | "version": "1.2.0", 4 | "description": "fold operator for tempest", 5 | "main": "dist/tempest-fold.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-fold.js -o dist/tempest-fold.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/fold/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-fold.js', 6 | format: 'umd', 7 | moduleName: 'tempestFold', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/fold/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { fold } from '../src/index' 6 | 7 | describe('@tempest/fold', () => { 8 | it ('should accumulate values over time', (done) => { 9 | const stream = fold((x, y) => x + y, 0, Stream.of(1, 1, 1)) 10 | const expected = [0, 1, 2, 3] 11 | 12 | stream.subscribe((x) => { 13 | assert(x === expected.shift()) 14 | }, done, () => done()) 15 | }) 16 | 17 | it ('should emit its seed value first', (done) => { 18 | const stream = fold((x, y) => x, 0, Stream.of()) 19 | const expected = [0] 20 | 21 | stream.subscribe((x) => { 22 | assert(x === expected.shift()) 23 | }, done, () => done()) 24 | }) 25 | 26 | it ('should be curried', (done) => { 27 | const add = fold((x, y) => x + y, 0) 28 | const stream = add(Stream.of(1, 1, 1)) 29 | const expected = [0, 1, 2, 3] 30 | 31 | stream.subscribe((x) => { 32 | assert(x === expected.shift()) 33 | }, done, () => done()) 34 | }) 35 | }) -------------------------------------------------------------------------------- /packages/fold/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/fold/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/fold", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/fromPromise/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/fromPromise/dist/tempest-fromPromise.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tempest/core')) : 3 | typeof define === 'function' && define.amd ? define(['exports', '@tempest/core'], factory) : 4 | (factory((global.tempestFromPromise = global.tempestFromPromise || {}),global.tempestCore)); 5 | }(this, function (exports,_tempest_core) { 'use strict'; 6 | 7 | function fromPromise(promise) { 8 | return new _tempest_core.Stream(new FromPromise(promise)); 9 | } 10 | var FromPromise = function FromPromise(promise) { 11 | this.promise = promise; 12 | }; 13 | FromPromise.prototype.run = function run (sink, scheduler) { 14 | var running = true; 15 | var promise = this.promise; 16 | promise.then(function (value) { 17 | if (!running) 18 | return; 19 | sink.event(scheduler.now(), value); 20 | }).catch(function (err) { 21 | sink.error(scheduler.now(), err); 22 | }).then(function () { 23 | sink.end(scheduler.now(), void 0); 24 | }); 25 | return { 26 | dispose: function dispose() { 27 | running = false; 28 | } 29 | }; 30 | }; 31 | 32 | exports.fromPromise = fromPromise; 33 | exports.FromPromise = FromPromise; 34 | 35 | Object.defineProperty(exports, '__esModule', { value: true }); 36 | 37 | })); 38 | //# sourceMappingURL=tempest-fromPromise.js.map 39 | -------------------------------------------------------------------------------- /packages/fromPromise/dist/tempest-fromPromise.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":null,"sources":["../lib/index.js"],"sourcesContent":["import { Stream } from '@tempest/core';\nexport function fromPromise(promise) {\n return new Stream(new FromPromise(promise));\n}\nexport class FromPromise {\n constructor(promise) {\n this.promise = promise;\n }\n run(sink, scheduler) {\n let running = true;\n const promise = this.promise;\n promise.then((value) => {\n if (!running)\n return;\n sink.event(scheduler.now(), value);\n }).catch((err) => {\n sink.error(scheduler.now(), err);\n }).then(() => {\n sink.end(scheduler.now(), void 0);\n });\n return {\n dispose() {\n running = false;\n }\n };\n }\n}\n//# sourceMappingURL=index.js.map"],"names":["Stream"],"mappings":";;;;;;IACO,SAAS,WAAW,CAAC,OAAO,EAAE;QACjC,OAAO,IAAIA,oBAAM,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;KAC/C;AACD,AAAO,IAAA,IAAM,WAAW,GAAC,oBACV,CAAC,OAAO,EAAE;QACrB,IAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;AAC/B,IAAA,CAAK,CAAA;AACL,IAAA,sBAAI,GAAG,iBAAC,IAAI,EAAE,SAAS,EAAE;QACrB,IAAQ,OAAO,GAAG,IAAI,CAAC;QACvB,IAAU,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QACjC,OAAW,CAAC,IAAI,CAAC,UAAC,KAAK,EAAE;YACrB,IAAQ,CAAC,OAAO;gBACZ,OAAW;YACf,IAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;SACtC,CAAC,CAAC,KAAK,CAAC,UAAC,GAAG,EAAE;YACf,IAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;SACpC,CAAC,CAAC,IAAI,CAAC,YAAG;YACX,IAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;SACrC,CAAC,CAAC;QACP,OAAW;YACP,OAAW,kBAAA,GAAG;gBACV,OAAW,GAAG,KAAK,CAAC;aACnB;SACJ,CAAC;AACV,IAAA,CAAK,CAAA;;;;;;;"} -------------------------------------------------------------------------------- /packages/fromPromise/dist/tempest-fromPromise.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestFromPromise=global.tempestFromPromise||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";function fromPromise(promise){return new _tempest_core.Stream(new FromPromise(promise))}var FromPromise=function FromPromise(promise){this.promise=promise};FromPromise.prototype.run=function run(sink,scheduler){var running=true;var promise=this.promise;promise.then(function(value){if(!running)return;sink.event(scheduler.now(),value)}).catch(function(err){sink.error(scheduler.now(),err)}).then(function(){sink.end(scheduler.now(),void 0)});return{dispose:function dispose(){running=false}}};exports.fromPromise=fromPromise;exports.FromPromise=FromPromise;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/fromPromise/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-fromPromise.js', 6 | format: 'umd', 7 | moduleName: 'tempestFromPromise', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/fromPromise/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Disposable, Scheduler } from '@tempest/core' 2 | 3 | export function fromPromise (promise: Promise): Stream { 4 | return new Stream(new FromPromise(promise)) 5 | } 6 | 7 | export class FromPromise implements Source { 8 | constructor (private promise: Promise) {} 9 | 10 | run (sink: Sink, scheduler: Scheduler): Disposable { 11 | let running: boolean = true 12 | const promise = this.promise 13 | 14 | promise.then((value: T) => { 15 | if (!running) return 16 | sink.event(scheduler.now(), value) 17 | }).catch((err: Error) => { 18 | sink.error(scheduler.now(), err) 19 | }).then(() => { 20 | sink.end(scheduler.now(), void 0) 21 | }) 22 | 23 | return { 24 | dispose () { 25 | running = false 26 | } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /packages/fromPromise/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { fromPromise } from '../src/index' 6 | 7 | describe('@tempest/fromPromise', () => { 8 | it ('should create a stream from a Promise', (done) => { 9 | const promise: Promise = Promise.resolve(123) 10 | const stream: Stream = fromPromise(promise) 11 | 12 | const expected = [123] 13 | 14 | stream.subscribe((x: number) => { 15 | assert(x === expected.shift()) 16 | }, done, () => done()) 17 | }) 18 | }) -------------------------------------------------------------------------------- /packages/fromPromise/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/fromPromise/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/fromPromise", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/last/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **last:** scheduler is not a generic ([c3f585a](https://github.com/TylorS/tempest/commit/c3f585a)) 8 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 9 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 10 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 11 | 12 | 13 | ### Features 14 | 15 | * **last:** implement last operator ([01c97f6](https://github.com/TylorS/tempest/commit/01c97f6)) 16 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /packages/last/dist/tempest-last.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tempest/core')) : 3 | typeof define === 'function' && define.amd ? define(['exports', '@tempest/core'], factory) : 4 | (factory((global.tempestLast = global.tempestLast || {}),global.tempestCore)); 5 | }(this, function (exports,_tempest_core) { 'use strict'; 6 | 7 | function last(stream) { 8 | return new _tempest_core.Stream(new Last(stream.source)); 9 | } 10 | var Last = function Last(source) { 11 | this.source = source; 12 | }; 13 | Last.prototype.run = function run (sink, scheduler) { 14 | return this.source.run(new LastSink(sink), scheduler); 15 | }; 16 | var LastSink = function LastSink(sink) { 17 | this.sink = sink; 18 | this.has = false; 19 | }; 20 | LastSink.prototype.event = function event (time, value) { 21 | this.has = true; 22 | this.value = value; 23 | }; 24 | LastSink.prototype.error = function error (time, err) { 25 | this.has = false; 26 | this.sink.error(time, err); 27 | }; 28 | LastSink.prototype.end = function end (time, value) { 29 | if (this.has) { 30 | this.sink.event(time, this.value); 31 | this.has = false; 32 | } 33 | this.sink.end(time, value); 34 | }; 35 | 36 | exports.last = last; 37 | exports.Last = Last; 38 | 39 | Object.defineProperty(exports, '__esModule', { value: true }); 40 | 41 | })); 42 | //# sourceMappingURL=tempest-last.js.map 43 | -------------------------------------------------------------------------------- /packages/last/dist/tempest-last.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":null,"sources":["../lib/index.js"],"sourcesContent":["import { Stream } from '@tempest/core';\nexport function last(stream) {\n return new Stream(new Last(stream.source));\n}\nexport class Last {\n constructor(source) {\n this.source = source;\n }\n run(sink, scheduler) {\n return this.source.run(new LastSink(sink), scheduler);\n }\n}\nclass LastSink {\n constructor(sink) {\n this.sink = sink;\n this.has = false;\n }\n event(time, value) {\n this.has = true;\n this.value = value;\n }\n error(time, err) {\n this.has = false;\n this.sink.error(time, err);\n }\n end(time, value) {\n if (this.has) {\n this.sink.event(time, this.value);\n this.has = false;\n }\n this.sink.end(time, value);\n }\n}\n//# sourceMappingURL=index.js.map"],"names":["Stream"],"mappings":";;;;;;IACO,SAAS,IAAI,CAAC,MAAM,EAAE;QACzB,OAAO,IAAIA,oBAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;KAC9C;AACD,AAAO,IAAA,IAAM,IAAI,GAAC,aACH,CAAC,MAAM,EAAE;QACpB,IAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;AAC7B,IAAA,CAAK,CAAA;AACL,IAAA,eAAI,GAAG,iBAAC,IAAI,EAAE,SAAS,EAAE;QACrB,OAAW,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;AAC9D,IAAA,CAAK,CAAA;AAEL,IAAA,IAAM,QAAQ,GAAC,iBACA,CAAC,IAAI,EAAE;QAClB,IAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;QACrB,IAAQ,CAAC,GAAG,GAAG,KAAK,CAAC;AACzB,IAAA,CAAK,CAAA;AACL,IAAA,mBAAI,KAAK,mBAAC,IAAI,EAAE,KAAK,EAAE;QACnB,IAAQ,CAAC,GAAG,GAAG,IAAI,CAAC;QACpB,IAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,IAAA,CAAK,CAAA;AACL,IAAA,mBAAI,KAAK,mBAAC,IAAI,EAAE,GAAG,EAAE;QACjB,IAAQ,CAAC,GAAG,GAAG,KAAK,CAAC;QACrB,IAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACnC,IAAA,CAAK,CAAA;AACL,IAAA,mBAAI,GAAG,iBAAC,IAAI,EAAE,KAAK,EAAE;QACjB,IAAQ,IAAI,CAAC,GAAG,EAAE;YACd,IAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YACtC,IAAQ,CAAC,GAAG,GAAG,KAAK,CAAC;SACpB;QACL,IAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACnC,IAAA,CAAK,CAAA;;;;;;;"} -------------------------------------------------------------------------------- /packages/last/dist/tempest-last.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestLast=global.tempestLast||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";function last(stream){return new _tempest_core.Stream(new Last(stream.source))}var Last=function Last(source){this.source=source};Last.prototype.run=function run(sink,scheduler){return this.source.run(new LastSink(sink),scheduler)};var LastSink=function LastSink(sink){this.sink=sink;this.has=false};LastSink.prototype.event=function event(time,value){this.has=true;this.value=value};LastSink.prototype.error=function error(time,err){this.has=false;this.sink.error(time,err)};LastSink.prototype.end=function end(time,value){if(this.has){this.sink.event(time,this.value);this.has=false}this.sink.end(time,value)};exports.last=last;exports.Last=Last;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/last/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/last", 3 | "version": "1.1.2", 4 | "description": "last operator for tempest", 5 | "main": "dist/tempest-last.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-last.js -o dist/tempest-last.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/last/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-last.js', 6 | format: 'umd', 7 | moduleName: 'tempestLast', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/last/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Disposable, Scheduler } from '@tempest/core' 2 | 3 | export function last (stream: Stream): Stream { 4 | return new Stream(new Last(stream.source)) 5 | } 6 | 7 | export class Last implements Source { 8 | constructor (private source: Source) {} 9 | 10 | run (sink: Sink, scheduler: Scheduler): Disposable { 11 | return this.source.run(new LastSink(sink), scheduler) 12 | } 13 | } 14 | 15 | class LastSink implements Sink { 16 | private has: boolean = false 17 | private value: T 18 | constructor (private sink: Sink) {} 19 | 20 | event (time: number, value: T) { 21 | this.has = true 22 | this.value = value 23 | } 24 | 25 | error (time: number, err: Error) { 26 | this.has = false 27 | this.sink.error(time, err) 28 | } 29 | 30 | end (time: number, value?: T) { 31 | if (this.has) { 32 | this.sink.event(time, this.value) 33 | this.has = false 34 | } 35 | this.sink.end(time, value) 36 | } 37 | } -------------------------------------------------------------------------------- /packages/last/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { last } from '../src/index' 6 | 7 | describe('@tempest/last', () => { 8 | it ('should only emit the last value of a stream', (done) => { 9 | const stream = last(Stream.from([1, 2, 3])) 10 | const expected = [3] 11 | stream.subscribe((value) => { 12 | assert(value === expected.shift()) 13 | }, done, () => done()) 14 | }) 15 | }) -------------------------------------------------------------------------------- /packages/last/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/last/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/last", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/map/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # 1.2.0 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **map:** scheduler is no loger a generic ([44d92aa](https://github.com/TylorS/tempest/commit/44d92aa)) 9 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 10 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 11 | 12 | 13 | ### Features 14 | 15 | * **map:** add mapTo implementation ([53b4189](https://github.com/TylorS/tempest/commit/53b4189)) 16 | * **map:** curry mapTo as well as map ([369d1ff](https://github.com/TylorS/tempest/commit/369d1ff)) 17 | * **map:** curry the external api ([5b107f8](https://github.com/TylorS/tempest/commit/5b107f8)) 18 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /packages/map/dist/tempest-map.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestMap=global.tempestMap||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";var map=function(f,stream){switch(arguments.length){case 1:return function(stream){return new _tempest_core.Stream(new Map(f,stream.source))};case 2:return new _tempest_core.Stream(new Map(f,stream.source));default:return map}};var mapTo=function(value,stream){switch(arguments.length){case 1:return function(stream){return map(function(){return value},stream)};case 2:return map(function(){return value},stream);default:return mapTo}};var Map=function Map(f,source){this.f=f;this.source=source};Map.prototype.run=function run(sink,scheduler){return this.source.run(new MapSink(this.f,sink),scheduler)};var MapSink=function MapSink(f,sink){this.f=f;this.sink=sink};MapSink.prototype.event=function event(time,value){var f=this.f;this.sink.event(time,f(value))};MapSink.prototype.error=function error(time,err){this.sink.error(time,err)};MapSink.prototype.end=function end(time,value){this.sink.end(time,value)};exports.map=map;exports.mapTo=mapTo;exports.Map=Map;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/map/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/map", 3 | "version": "1.2.0", 4 | "description": "Map operator for tempest", 5 | "main": "dist/tempest-map.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-map.js -o dist/tempest-map.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "map", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/map/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-map.js', 6 | format: 'umd', 7 | moduleName: 'tempestMap', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/map/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { map, mapTo } from '../src/index' 6 | 7 | describe ('map', () => { 8 | it ('should map event values from T to R', (done) => { 9 | const stream = Stream.of(1) 10 | map((x: number) => x + 1, stream).subscribe((x: number) => { 11 | assert(x === 2) 12 | }, done, () => done()) 13 | }) 14 | 15 | it ('should be curried', (done) => { 16 | const f = (x: number) => x + 1 17 | const stream = Stream.of(1) 18 | const add1 = map(f) 19 | add1(stream).subscribe((x: number) => { 20 | assert(x === 2) 21 | }, done, () => done()) 22 | }) 23 | }) 24 | 25 | describe('mapTo', () => { 26 | it ('should map event values from T to R', (done) => { 27 | const stream = Stream.of(1) 28 | mapTo(2, stream).subscribe((x: number) => { 29 | assert(x === 2) 30 | }, done, () => done()) 31 | }) 32 | 33 | it ('should be curried', (done) => { 34 | const f = 2 35 | const stream = Stream.of(1) 36 | const add1 = mapTo(f) 37 | add1(stream).subscribe((x: number) => { 38 | assert(x === 2) 39 | }, done, () => done()) 40 | }) 41 | }) -------------------------------------------------------------------------------- /packages/map/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/map/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/map", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/merge/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **merge:** use local getSource instead of one from core ([7b62d94](https://github.com/TylorS/tempest/commit/7b62d94)) 9 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 10 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 11 | 12 | 13 | ### Features 14 | 15 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /packages/merge/dist/tempest-merge.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestMerge=global.tempestMerge||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";function merge(streams){return new _tempest_core.Stream(new Merge(streams.map(getSource)))}function getSource(stream){return stream.source}var Merge=function Merge(sources){this.sources=sources};Merge.prototype.run=function run(sink,scheduler){var this$1=this;var length=this.sources.length;var disposables=new Array(length);var sinks=new Array(length);var mergeSink=new MergeSink(disposables,sinks,sink);var indexSink;for(var i=0;i (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/merge/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-merge.js', 6 | format: 'umd', 7 | moduleName: 'tempestMerge', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/merge/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { merge } from '../src/index' 6 | 7 | describe('@tempest/merge', () => { 8 | it ('should merge multiple streams into 1', (done) => { 9 | const stream = merge([ 10 | Stream.of(1), 11 | Stream.of(2), 12 | Stream.of(3) 13 | ]) 14 | 15 | const expected = [1, 2, 3] 16 | 17 | stream.subscribe((x) => { 18 | assert(x === expected.shift()) 19 | }, done, () => { 20 | assert(expected.length === 0) 21 | done() 22 | }) 23 | }) 24 | }) -------------------------------------------------------------------------------- /packages/merge/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/merge/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/merge", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/never/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/never/dist/tempest-never.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tempest/core')) : 3 | typeof define === 'function' && define.amd ? define(['exports', '@tempest/core'], factory) : 4 | (factory((global.tempestNever = global.tempestNever || {}),global.tempestCore)); 5 | }(this, function (exports,_tempest_core) { 'use strict'; 6 | 7 | var Never = function Never () {}; 8 | 9 | Never.prototype.run = function run (sink, scheduler) { 10 | return { 11 | dispose: function dispose() { 12 | return void 0; 13 | } 14 | }; 15 | }; 16 | var NEVER = new _tempest_core.Stream(new Never()); 17 | function never() { 18 | return NEVER; 19 | } 20 | 21 | exports.Never = Never; 22 | exports.never = never; 23 | 24 | Object.defineProperty(exports, '__esModule', { value: true }); 25 | 26 | })); 27 | //# sourceMappingURL=tempest-never.js.map 28 | -------------------------------------------------------------------------------- /packages/never/dist/tempest-never.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":null,"sources":["../lib/index.js"],"sourcesContent":["import { Stream } from '@tempest/core';\nexport class Never {\n run(sink, scheduler) {\n return {\n dispose() {\n return void 0;\n }\n };\n }\n}\nconst NEVER = new Stream(new Never());\nexport function never() {\n return NEVER;\n}\n//# sourceMappingURL=index.js.map"],"names":["const","Stream"],"mappings":";;;;;;IACO,IAAM,KAAK,GAAC;;AAAA,IAAA,gBACf,GAAG,iBAAC,IAAI,EAAE,SAAS,EAAE;QACrB,OAAW;YACP,OAAW,kBAAA,GAAG;gBACV,OAAW,KAAK,CAAC,CAAC;aACjB;SACJ,CAAC;AACV,IAAA,CAAK,CAAA;AAELA,IAAAA,IAAM,KAAK,GAAG,IAAIC,oBAAM,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;AACtC,AAAO,IAAA,SAAS,KAAK,GAAG;QACpB,OAAO,KAAK,CAAC;KAChB;;;;;;;"} -------------------------------------------------------------------------------- /packages/never/dist/tempest-never.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestNever=global.tempestNever||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";var Never=function Never(){};Never.prototype.run=function run(sink,scheduler){return{dispose:function dispose(){return void 0}}};var NEVER=new _tempest_core.Stream(new Never);function never(){return NEVER}exports.Never=Never;exports.never=never;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/never/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/never", 3 | "version": "1.1.2", 4 | "description": "never operator for tempest", 5 | "main": "dist/tempest-never.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-never.js -o dist/tempest-never.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/never/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-never.js', 6 | format: 'umd', 7 | moduleName: 'tempestNever', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/never/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Disposable, Scheduler } from '@tempest/core' 2 | 3 | export class Never implements Source { 4 | run (sink: Sink, scheduler: Scheduler): Disposable { 5 | return { 6 | dispose () { 7 | return void 0 8 | } 9 | } 10 | } 11 | } 12 | 13 | const NEVER = new Stream(new Never()) 14 | 15 | export function never (): Stream { 16 | return NEVER 17 | } -------------------------------------------------------------------------------- /packages/never/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { never } from '../src/index' 6 | 7 | describe('@tempest/never', () => { 8 | it ('should create a stream that never emits', (done) => { 9 | const stream = never() 10 | assert(stream instanceof Stream) 11 | 12 | const subscription = stream.subscribe(done, done, done) 13 | 14 | setTimeout(() => { 15 | subscription.unsubscribe() 16 | done() 17 | }, 1000) 18 | }) 19 | }) -------------------------------------------------------------------------------- /packages/never/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/never/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/never", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/periodic/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/periodic/dist/tempest-periodic.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tempest/core')) : 3 | typeof define === 'function' && define.amd ? define(['exports', '@tempest/core'], factory) : 4 | (factory((global.tempestPeriodic = global.tempestPeriodic || {}),global.tempestCore)); 5 | }(this, function (exports,_tempest_core) { 'use strict'; 6 | 7 | function periodic(period) { 8 | return new _tempest_core.Stream(new Periodic(period)); 9 | } 10 | var Periodic = function Periodic(period) { 11 | this.period = period; 12 | }; 13 | Periodic.prototype.run = function run (sink, scheduler) { 14 | var task = new _tempest_core.PropagateTask(makeRun(-1), void 0, sink); 15 | var scheduledTask = scheduler.periodic(this.period, task); 16 | return { 17 | dispose: function dispose() { 18 | scheduler.cancel(scheduledTask); 19 | } 20 | }; 21 | }; 22 | function makeRun(i) { 23 | return function run(time, value, sink) { 24 | sink.event(time, ++i); 25 | }; 26 | } 27 | 28 | exports.periodic = periodic; 29 | exports.Periodic = Periodic; 30 | 31 | Object.defineProperty(exports, '__esModule', { value: true }); 32 | 33 | })); 34 | //# sourceMappingURL=tempest-periodic.js.map 35 | -------------------------------------------------------------------------------- /packages/periodic/dist/tempest-periodic.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":null,"sources":["../lib/index.js"],"sourcesContent":["import { Stream, PropagateTask } from '@tempest/core';\nexport function periodic(period) {\n return new Stream(new Periodic(period));\n}\nexport class Periodic {\n constructor(period) {\n this.period = period;\n }\n run(sink, scheduler) {\n const task = new PropagateTask(makeRun(-1), void 0, sink);\n const scheduledTask = scheduler.periodic(this.period, task);\n return {\n dispose() {\n scheduler.cancel(scheduledTask);\n }\n };\n }\n}\nfunction makeRun(i) {\n return function run(time, value, sink) {\n sink.event(time, ++i);\n };\n}\n//# sourceMappingURL=index.js.map"],"names":["Stream","PropagateTask"],"mappings":";;;;;;IACO,SAAS,QAAQ,CAAC,MAAM,EAAE;QAC7B,OAAO,IAAIA,oBAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;KAC3C;AACD,AAAO,IAAA,IAAM,QAAQ,GAAC,iBACP,CAAC,MAAM,EAAE;QACpB,IAAQ,CAAC,MAAM,GAAG,MAAM,CAAC;AAC7B,IAAA,CAAK,CAAA;AACL,IAAA,mBAAI,GAAG,iBAAC,IAAI,EAAE,SAAS,EAAE;QACrB,IAAU,IAAI,GAAG,IAAIC,2BAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;QAC9D,IAAU,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAChE,OAAW;YACP,OAAW,kBAAA,GAAG;gBACV,SAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;aACnC;SACJ,CAAC;AACV,IAAA,CAAK,CAAA;AAEL,IAAA,SAAS,OAAO,CAAC,CAAC,EAAE;QAChB,OAAO,SAAS,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;YACnC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;SACzB,CAAC;KACL;;;;;;;"} -------------------------------------------------------------------------------- /packages/periodic/dist/tempest-periodic.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestPeriodic=global.tempestPeriodic||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";function periodic(period){return new _tempest_core.Stream(new Periodic(period))}var Periodic=function Periodic(period){this.period=period};Periodic.prototype.run=function run(sink,scheduler){var task=new _tempest_core.PropagateTask(makeRun(-1),(void 0),sink);var scheduledTask=scheduler.periodic(this.period,task);return{dispose:function dispose(){scheduler.cancel(scheduledTask)}}};function makeRun(i){return function run(time,value,sink){sink.event(time,++i)}}exports.periodic=periodic;exports.Periodic=Periodic;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/periodic/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/periodic", 3 | "version": "1.1.2", 4 | "description": "periodic factory for tempest", 5 | "main": "dist/tempest-periodic.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-periodic.js -o dist/tempest-periodic.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/periodic/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-periodic.js', 6 | format: 'umd', 7 | moduleName: 'tempestPeriodic', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/periodic/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Disposable, Scheduler, PropagateTask } from '@tempest/core' 2 | 3 | export function periodic (period: number): Stream { 4 | return new Stream(new Periodic(period)) 5 | } 6 | 7 | export class Periodic implements Source { 8 | constructor (private period: number) {} 9 | 10 | run (sink: Sink, scheduler: Scheduler): Disposable { 11 | const task = new PropagateTask(makeRun(-1), void 0, sink) 12 | const scheduledTask = scheduler.periodic(this.period, task) 13 | 14 | return { 15 | dispose () { 16 | scheduler.cancel(scheduledTask) 17 | } 18 | } 19 | } 20 | } 21 | 22 | function makeRun (i: number) { 23 | return function run (time: number, value: number, sink: Sink) { 24 | sink.event(time, ++i) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/periodic/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { periodic } from '../src/index' 6 | 7 | describe('@tempest/periodic', () => { 8 | it ('should create a stream of incrementing numbers', (done) => { 9 | const stream: Stream = periodic(100) 10 | const expected = [0, 1, 2, 3] 11 | 12 | const sub = stream.subscribe((x) => { 13 | assert(x === expected.shift()) 14 | if (expected.length === 0) { 15 | sub.unsubscribe() 16 | done() 17 | } 18 | }) 19 | }) 20 | }) -------------------------------------------------------------------------------- /packages/periodic/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/periodic/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/periodic", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/proxy/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/proxy/dist/tempest-proxy.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestProxy=global.tempestProxy||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";function proxy(){var source=new ProxySource;var stream=new _tempest_core.Stream(source);function attach(origin){source.add(origin.source);return origin}return{attach:attach,stream:stream}}var ProxySource=function ProxySource(){this.sink=void 0;this.active=false;this.source=void 0;this.disposable=void 0};ProxySource.prototype.run=function run(sink,scheduler){this.sink=sink;this.active=true;if(this.source!==void 0){this.disposable=this.source.run(sink,scheduler)}return this};ProxySource.prototype.dispose=function dispose(){this.active=false;this.disposable.dispose()};ProxySource.prototype.add=function add(source){if(this.active){this.source=source;this.disposable=source.run(this.sink,_tempest_core.defaultScheduler)}else if(!this.source){this.source=source;return}else{throw new Error("Can only attach to one stream")}};ProxySource.prototype.event=function event(t,x){if(this.sink===void 0){return}this.ensureActive();this.sink.event(t,x)};ProxySource.prototype.end=function end(t,x){this.propagateAndDisable(this.sink.end,t,x)};ProxySource.prototype.error=function error(t,e){this.propagateAndDisable(this.sink.error,t,e)};ProxySource.prototype.propagateAndDisable=function propagateAndDisable(method,t,x){if(this.sink===void 0){return}this.ensureActive();this.active=false;var sink=this.sink;this.sink=void 0;method.call(sink,t,x)};ProxySource.prototype.ensureActive=function ensureActive(){if(!this.active){throw new Error("stream has already ended")}};exports.proxy=proxy;exports.ProxySource=ProxySource;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/proxy/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/proxy", 3 | "version": "1.1.2", 4 | "description": "proxy operator for tempest", 5 | "main": "dist/tempest-proxy.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-proxy.js -o dist/tempest-proxy.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/proxy/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-proxy.js', 6 | format: 'umd', 7 | moduleName: 'tempestProxy', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/proxy/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { proxy } from '../src/index' 6 | 7 | describe('@tempest/proxy', () => { 8 | it ('should create a circular dependency', (done) => { 9 | const { attach, stream } = proxy() 10 | attach(Stream.of(1, 2, 3)) 11 | 12 | const expected = [1, 2, 3] 13 | 14 | stream.subscribe((x: number) => { 15 | assert(x === expected.shift()) 16 | }, done, () => done()) 17 | }) 18 | 19 | it ('should not start the stream until actively observed', (done) => { 20 | const { attach, stream } = proxy() 21 | attach(Stream.of(1, 2, 3)) 22 | 23 | const expected = [1, 2, 3] 24 | 25 | setTimeout(() => { 26 | stream.subscribe((x: number) => { 27 | assert(x === expected.shift()) 28 | }, done, () => done()) 29 | }) 30 | }) 31 | }) -------------------------------------------------------------------------------- /packages/proxy/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/proxy/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/proxy", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/remember/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **remember:** implement remember and MemoryStream ([15804a4](https://github.com/TylorS/tempest/commit/15804a4)) 15 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /packages/remember/dist/tempest-remember.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":null,"sources":["../lib/index.js"],"sourcesContent":["import { Stream, Multicast } from '@tempest/core';\nexport function remember(stream) {\n return new MemoryStream(stream.source);\n}\nexport class MemoryStream extends Stream {\n constructor(source) {\n super(source);\n this.source = new Memory(source);\n }\n}\nexport class Memory extends Multicast {\n constructor(source) {\n super(source);\n this.has = false;\n this.value = void 0;\n }\n _add(sink) {\n if (this.has) {\n sink.event(Date.now(), this.value);\n }\n return super._add(sink);\n }\n event(time, value) {\n this.has = true;\n this.value = value;\n super.event(time, value);\n }\n}\n//# sourceMappingURL=index.js.map"],"names":["super","Stream","Multicast"],"mappings":";;;;;;IACO,SAAS,QAAQ,CAAC,MAAM,EAAE;QAC7B,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KAC1C;AACD,AAAO,IAAA,IAAM,YAAY,GAAe;QAAC,qBAC1B,CAAC,MAAM,EAAE;YAChBA,MAAK,KAAA,CAAC,MAAA,MAAM,CAAC,CAAC;YACd,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;SACpC;;;;0DAAA;;;MAJ6BC,oBAKjC,GAAA;AACD,AAAO,IAAA,IAAM,MAAM,GAAkB;QAAC,eACvB,CAAC,MAAM,EAAE;YAChBD,SAAK,KAAA,CAAC,MAAA,MAAM,CAAC,CAAC;YACd,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;YACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;SACvB;;;;8CAAA;QACD,iBAAA,IAAI,kBAAC,IAAI,EAAE;YACP,IAAI,IAAI,CAAC,GAAG,EAAE;gBACV,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;aACtC;YACD,OAAOA,mBAAK,CAAC,IAAI,KAAA,CAAC,MAAA,IAAI,CAAC,CAAC;SAC3B,CAAA;QACD,iBAAA,KAAK,mBAAC,IAAI,EAAE,KAAK,EAAE;YACf,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;YAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnBA,mBAAK,CAAC,KAAK,KAAA,CAAC,MAAA,IAAI,EAAE,KAAK,CAAC,CAAC;SAC5B,CAAA;;;MAhBuBE,uBAiB3B,GAAA;;;;;;;;"} -------------------------------------------------------------------------------- /packages/remember/dist/tempest-remember.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestRemember=global.tempestRemember||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";function remember(stream){return new MemoryStream(stream.source)}var MemoryStream=function(Stream){function MemoryStream(source){Stream.call(this,source);this.source=new Memory(source)}if(Stream)MemoryStream.__proto__=Stream;MemoryStream.prototype=Object.create(Stream&&Stream.prototype);MemoryStream.prototype.constructor=MemoryStream;return MemoryStream}(_tempest_core.Stream);var Memory=function(Multicast){function Memory(source){Multicast.call(this,source);this.has=false;this.value=void 0}if(Multicast)Memory.__proto__=Multicast;Memory.prototype=Object.create(Multicast&&Multicast.prototype);Memory.prototype.constructor=Memory;Memory.prototype._add=function _add(sink){if(this.has){sink.event(Date.now(),this.value)}return Multicast.prototype._add.call(this,sink)};Memory.prototype.event=function event(time,value){this.has=true;this.value=value;Multicast.prototype.event.call(this,time,value)};return Memory}(_tempest_core.Multicast);exports.remember=remember;exports.MemoryStream=MemoryStream;exports.Memory=Memory;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/remember/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-remember.js', 6 | format: 'umd', 7 | moduleName: 'tempestRemember', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/remember/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Multicast } from '@tempest/core' 2 | 3 | export function remember (stream: Stream) { 4 | return new MemoryStream(stream.source) 5 | } 6 | 7 | export class MemoryStream extends Stream { 8 | public source: Memory 9 | constructor (source: Source) { 10 | super(source) 11 | this.source = new Memory(source) 12 | } 13 | } 14 | 15 | export class Memory extends Multicast { 16 | private has: boolean = false 17 | private value: T = void 0 18 | constructor (source: Source) { 19 | super(source) 20 | } 21 | 22 | _add (sink: Sink) { 23 | if (this.has) { 24 | sink.event(Date.now(), this.value) 25 | } 26 | return super._add(sink) 27 | } 28 | 29 | event (time: number, value: T) { 30 | this.has = true 31 | this.value = value 32 | super.event(time, value) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/remember/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream, Sink, Scheduler, PropagateTask } from '@tempest/core' 5 | import { remember } from '../src/index' 6 | 7 | describe('@tempest/remember', () => { 8 | it ('should remember the last value for a late subscriber', (done) => { 9 | const stream = new Stream({ 10 | run (sink: Sink, scheduler: Scheduler) { 11 | let i = -1 12 | const interval = setInterval(() => { 13 | sink.event(scheduler.now(), ++i) 14 | }, 50) 15 | 16 | return { 17 | dispose () { 18 | clearInterval(interval) 19 | } 20 | } 21 | } 22 | }) 23 | 24 | const rstream = remember(stream) 25 | 26 | stream.subscribe() 27 | setTimeout(() => { 28 | rstream.subscribe((x: number) => { 29 | assert(x === 1) 30 | done() 31 | }) 32 | }, 80) 33 | }) 34 | }) -------------------------------------------------------------------------------- /packages/remember/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/remember/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/remember", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/replaceError/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # 1.2.0 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **replaceError:** curry the external API ([c85d39c](https://github.com/TylorS/tempest/commit/c85d39c)) 15 | * **replaceError:** implement replaceError operator ([b4428d8](https://github.com/TylorS/tempest/commit/b4428d8)) 16 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /packages/replaceError/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-replaceError.js', 6 | format: 'umd', 7 | moduleName: 'tempestReplaceError', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/replaceError/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream, Sink, Scheduler, PropagateTask } from '@tempest/core' 5 | import { replaceError } from '../src/index' 6 | 7 | describe('@tempest/replaceError', () => { 8 | it ('should allow replacing a stream after an error', (done) => { 9 | const errorStream = new Stream({ 10 | run (sink: Sink, scheduler: Scheduler) { 11 | const task = scheduler.asap(PropagateTask.error(new Error('oh no'), sink)) 12 | return { 13 | dispose () { 14 | scheduler.cancel(task) 15 | } 16 | } 17 | } 18 | }) 19 | 20 | const replace = (e: Error) => Stream.of(1) 21 | 22 | const stream = replaceError(replace, errorStream) 23 | 24 | stream.subscribe((x: number) => { 25 | assert(x === 1) 26 | }, done, () => done()) 27 | }) 28 | 29 | it ('should be curried', (done) => { 30 | const errorStream = new Stream({ 31 | run (sink: Sink, scheduler: Scheduler) { 32 | const task = scheduler.asap(PropagateTask.error(new Error('oh no'), sink)) 33 | return { 34 | dispose () { 35 | scheduler.cancel(task) 36 | } 37 | } 38 | } 39 | }) 40 | 41 | const replace = (e: Error) => Stream.of(1) 42 | 43 | const replaceWith = replaceError(replace) 44 | const stream = replaceWith(errorStream) 45 | 46 | stream.subscribe((x: number) => { 47 | assert(x === 1) 48 | }, done, () => done()) 49 | }) 50 | }) -------------------------------------------------------------------------------- /packages/replaceError/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/replaceError/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/replaceError", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/sample/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # 1.2.0 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **sample:** curry the external API ([bd4179b](https://github.com/TylorS/tempest/commit/bd4179b)) 15 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /packages/sample/dist/tempest-sample.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestSample=global.tempestSample||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";var sample=function(sampler,stream){switch(arguments.length){case 1:return function(stream){return new _tempest_core.Stream(new Sample(sampler.source,stream.source))};case 2:return new _tempest_core.Stream(new Sample(sampler.source,stream.source));default:return sample}};var Sample=function Sample(sampler,source){this.sampler=sampler;this.source=source};Sample.prototype.run=function run(sink,scheduler){var sampleSink=new SampleSink(sink);var samplerDisposable=this.sampler.run(sampleSink,scheduler);var sourceDisposable=this.source.run(sampleSink.hold,scheduler);return new SampleDisposable(samplerDisposable,sourceDisposable)};var SampleSink=function SampleSink(sink){this.sink=sink;this.hold=new SampleHold(this)};SampleSink.prototype.event=function event(time,value){if(this.hold.hasValue){this.sink.event(time,this.hold.value)}};SampleSink.prototype.error=function error(time,err){this.sink.error(time,err)};SampleSink.prototype.end=function end(time,value){this.sink.end(time,this.hold.value)};var SampleHold=function SampleHold(sink){this.sink=sink;this.hasValue=false;this.value=void 0};SampleHold.prototype.event=function event(time,value){this.hasValue=true;this.value=value};SampleHold.prototype.error=function error(time,err){this.sink.error(time,err)};SampleHold.prototype.end=function end(time,value){return void 0};var SampleDisposable=function SampleDisposable(sampleDisposable,sourceDisposable){this.sampleDisposable=sampleDisposable;this.sourceDisposable=sourceDisposable};SampleDisposable.prototype.dispose=function dispose(){this.sampleDisposable.dispose();this.sourceDisposable.dispose()};exports.sample=sample;exports.Sample=Sample;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/sample/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/sample", 3 | "version": "1.2.0", 4 | "description": "sample operator for tempest", 5 | "main": "dist/tempest-sample.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-sample.js -o dist/tempest-sample.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/sample/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-sample.js', 6 | format: 'umd', 7 | moduleName: 'tempestSample', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/sample/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/sample/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/sample", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/startWith/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # 1.2.0 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **startWith:** curry the external API ([6fec2d0](https://github.com/TylorS/tempest/commit/6fec2d0)) 15 | * **startWith:** implement startWith ([7b2dc1b](https://github.com/TylorS/tempest/commit/7b2dc1b)) 16 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /packages/startWith/dist/tempest-startWith.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tempest/core')) : 3 | typeof define === 'function' && define.amd ? define(['exports', '@tempest/core'], factory) : 4 | (factory((global.tempestStartWith = global.tempestStartWith || {}),global.tempestCore)); 5 | }(this, function (exports,_tempest_core) { 'use strict'; 6 | 7 | var startWith = function (value, stream) { 8 | switch (arguments.length) { 9 | case 1: return function (stream) { return new _tempest_core.Stream(new StartWith(value, stream.source)); }; 10 | case 2: return new _tempest_core.Stream(new StartWith(value, stream.source)); 11 | default: return startWith; 12 | } 13 | }; 14 | var StartWith = function StartWith(value, source) { 15 | this.value = value; 16 | this.source = source; 17 | }; 18 | StartWith.prototype.run = function run (sink, scheduler) { 19 | scheduler.asap(_tempest_core.PropagateTask.event(this.value, sink)); 20 | return this.source.run(new StartWithSink(this.value, sink), scheduler); 21 | }; 22 | var StartWithSink = function StartWithSink(value, sink) { 23 | this.value = value; 24 | this.sink = sink; 25 | }; 26 | StartWithSink.prototype.event = function event (time, value) { 27 | this.sink.event(time, value); 28 | }; 29 | StartWithSink.prototype.error = function error (time, err) { 30 | this.sink.error(time, err); 31 | }; 32 | StartWithSink.prototype.end = function end (time, value) { 33 | this.sink.end(time, value); 34 | }; 35 | 36 | exports.startWith = startWith; 37 | exports.StartWith = StartWith; 38 | 39 | Object.defineProperty(exports, '__esModule', { value: true }); 40 | 41 | })); 42 | //# sourceMappingURL=tempest-startWith.js.map 43 | -------------------------------------------------------------------------------- /packages/startWith/dist/tempest-startWith.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestStartWith=global.tempestStartWith||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";var startWith=function(value,stream){switch(arguments.length){case 1:return function(stream){return new _tempest_core.Stream(new StartWith(value,stream.source))};case 2:return new _tempest_core.Stream(new StartWith(value,stream.source));default:return startWith}};var StartWith=function StartWith(value,source){this.value=value;this.source=source};StartWith.prototype.run=function run(sink,scheduler){scheduler.asap(_tempest_core.PropagateTask.event(this.value,sink));return this.source.run(new StartWithSink(this.value,sink),scheduler)};var StartWithSink=function StartWithSink(value,sink){this.value=value;this.sink=sink};StartWithSink.prototype.event=function event(time,value){this.sink.event(time,value)};StartWithSink.prototype.error=function error(time,err){this.sink.error(time,err)};StartWithSink.prototype.end=function end(time,value){this.sink.end(time,value)};exports.startWith=startWith;exports.StartWith=StartWith;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/startWith/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-startWith.js', 6 | format: 'umd', 7 | moduleName: 'tempestStartWith', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/startWith/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Disposable, Scheduler } from '@tempest/core' 2 | import { PropagateTask } from '@tempest/core' 3 | 4 | export interface StartWithCurried { 5 | (): (value: T, stream: Stream) => Stream 6 | (value: T): (stream: Stream) => Stream 7 | (value: T, stream: Stream): Stream 8 | } 9 | 10 | export const startWith: StartWithCurried = function (value: T, stream: Stream): Stream | 11 | ((stream: Stream) => Stream) | ((value: T, stream: Stream) => Stream) { 12 | switch (arguments.length) { 13 | case 1: return function (stream: Stream) { return new Stream(new StartWith(value, stream.source)) } 14 | case 2: return new Stream(new StartWith(value, stream.source)) 15 | default: return startWith 16 | } 17 | } 18 | 19 | export class StartWith implements Source { 20 | constructor (private value: T, private source: Source) {} 21 | 22 | run (sink: Sink, scheduler: Scheduler): Disposable { 23 | scheduler.asap(PropagateTask.event(this.value, sink)) 24 | return this.source.run(new StartWithSink(this.value, sink), scheduler) 25 | } 26 | } 27 | 28 | class StartWithSink implements Sink { 29 | constructor (private value: T, private sink: Sink) { 30 | } 31 | 32 | event (time: number, value: T) { 33 | this.sink.event(time, value) 34 | } 35 | 36 | error (time: number, err: Error) { 37 | this.sink.error(time, err) 38 | } 39 | 40 | end (time: number, value?: T) { 41 | this.sink.end(time, value) 42 | } 43 | } -------------------------------------------------------------------------------- /packages/startWith/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { startWith } from '../src/index' 6 | 7 | describe('@tempest/startWith', () => { 8 | it ('should start with a value an continue emittting as normal', (done) => { 9 | const stream = startWith(0, Stream.of(1, 2, 3)) 10 | const expected = [0, 1, 2, 3] 11 | 12 | stream.subscribe({ 13 | next: (x: number) => { 14 | assert(x === expected.shift()) 15 | }, 16 | error: done, 17 | complete: () => done() 18 | }) 19 | }) 20 | 21 | it ('should be curried', (done) => { 22 | const startWithZero = startWith(0) 23 | const stream = startWithZero(Stream.of(1, 2, 3)) 24 | const expected = [0, 1, 2, 3] 25 | 26 | stream.subscribe({ 27 | next: (x: number) => { 28 | assert(x === expected.shift()) 29 | }, 30 | error: done, 31 | complete: () => done() 32 | }) 33 | }) 34 | }) -------------------------------------------------------------------------------- /packages/startWith/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/startWith/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/startWith", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/subject/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/subject/dist/tempest-subject.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":null,"sources":["../lib/index.js"],"sourcesContent":["import { Stream, defaultScheduler, PropagateTask } from '@tempest/core';\n/**\n * Takes a Stream and 'upgrades' it to a Subject\n *\n * @export\n * @template T\n * @param {Stream} stream\n * @returns {Subject}\n * @example\n * import { never } from '@tempest/never'\n * import { asSubject } from '@tempest/subject'\n *\n * const subject = asSubject(never())\n *\n * subject.subscribe(x => console.log(x)) // 1, 2, 3\n *\n * subject.next(1)\n * subject.next(2)\n * subject.next(3)\n * subject.complete()\n */\nexport function asSubject(stream) {\n return new Subject(stream.source);\n}\nexport class Subject extends Stream {\n constructor(source) {\n super(source);\n }\n next(value) {\n defaultScheduler.asap(PropagateTask.event(value, this.source));\n }\n error(err) {\n defaultScheduler.asap(PropagateTask.error(err, this.source));\n }\n complete(value) {\n defaultScheduler.asap(PropagateTask.end(value, this.source));\n }\n}\n//# sourceMappingURL=index.js.map"],"names":["super","defaultScheduler","PropagateTask","Stream"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,AAAO,IAAA,SAAS,SAAS,CAAC,MAAM,EAAE;QAC9B,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;KACrC;AACD,AAAO,IAAA,IAAM,OAAO,GAAe;QAAC,gBACrB,CAAC,MAAM,EAAE;YAChBA,MAAK,KAAA,CAAC,MAAA,MAAM,CAAC,CAAC;SACjB;;;;gDAAA;QACD,kBAAA,IAAI,kBAAC,KAAK,EAAE;YACRC,8BAAgB,CAAC,IAAI,CAACC,2BAAa,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SAClE,CAAA;QACD,kBAAA,KAAK,mBAAC,GAAG,EAAE;YACPD,8BAAgB,CAAC,IAAI,CAACC,2BAAa,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SAChE,CAAA;QACD,kBAAA,QAAQ,sBAAC,KAAK,EAAE;YACZD,8BAAgB,CAAC,IAAI,CAACC,2BAAa,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SAChE,CAAA;;;MAZwBC,oBAa5B,GAAA;;;;;;;"} -------------------------------------------------------------------------------- /packages/subject/dist/tempest-subject.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestSubject=global.tempestSubject||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";function asSubject(stream){return new Subject(stream.source)}var Subject=function(Stream){function Subject(source){Stream.call(this,source)}if(Stream)Subject.__proto__=Stream;Subject.prototype=Object.create(Stream&&Stream.prototype);Subject.prototype.constructor=Subject;Subject.prototype.next=function next(value){_tempest_core.defaultScheduler.asap(_tempest_core.PropagateTask.event(value,this.source))};Subject.prototype.error=function error(err){_tempest_core.defaultScheduler.asap(_tempest_core.PropagateTask.error(err,this.source))};Subject.prototype.complete=function complete(value){_tempest_core.defaultScheduler.asap(_tempest_core.PropagateTask.end(value,this.source))};return Subject}(_tempest_core.Stream);exports.asSubject=asSubject;exports.Subject=Subject;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/subject/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/subject", 3 | "version": "1.1.2", 4 | "description": "subject operator for tempest", 5 | "main": "dist/tempest-subject.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-subject.js -o dist/tempest-subject.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "drop", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/subject/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-subject.js', 6 | format: 'umd', 7 | moduleName: 'tempestSubject', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/subject/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, defaultScheduler, PropagateTask } from '@tempest/core' 2 | 3 | /** 4 | * Takes a Stream and 'upgrades' it to a Subject 5 | * 6 | * @export 7 | * @template T 8 | * @param {Stream} stream 9 | * @returns {Subject} 10 | * @example 11 | * import { never } from '@tempest/never' 12 | * import { asSubject } from '@tempest/subject' 13 | * 14 | * const subject = asSubject(never()) 15 | * 16 | * subject.subscribe(x => console.log(x)) // 1, 2, 3 17 | * 18 | * subject.next(1) 19 | * subject.next(2) 20 | * subject.next(3) 21 | * subject.complete() 22 | */ 23 | export function asSubject (stream: Stream): Subject { 24 | return new Subject(stream.source) 25 | } 26 | 27 | export class Subject extends Stream { 28 | constructor (source: Source) { 29 | super(source) 30 | } 31 | 32 | next (value: T) { 33 | defaultScheduler.asap(PropagateTask.event(value, this.source)) 34 | } 35 | 36 | error (err: Error) { 37 | defaultScheduler.asap(PropagateTask.error(err, this.source)) 38 | } 39 | 40 | complete (value?: T) { 41 | defaultScheduler.asap(PropagateTask.end(value, this.source)) 42 | } 43 | } -------------------------------------------------------------------------------- /packages/subject/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream, Sink, Scheduler } from '@tempest/core' 5 | import { asSubject } from '../src/index' 6 | 7 | describe('@tempest/subject', () => { 8 | describe('subject()', () => { 9 | it ('should create a Subject', (done) => { 10 | const s = asSubject(new Stream({ 11 | run (sink: Sink, scheduler: Scheduler) { 12 | return { 13 | dispose () { 14 | return void 0 15 | } 16 | } 17 | } 18 | })) 19 | assert(s instanceof Stream) 20 | const expected = [1, 2, 3] 21 | 22 | s.subscribe((x) => { 23 | assert(x === expected.shift()) 24 | }, done, () => done()) 25 | 26 | s.next(1) 27 | s.next(2) 28 | s.next(3) 29 | s.complete() 30 | }) 31 | }) 32 | }) -------------------------------------------------------------------------------- /packages/subject/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/subject/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/subject", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/take/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # 1.2.0 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | * **package:** add jsnext:main and typings field to package.json ([3cbbc88](https://github.com/TylorS/tempest/commit/3cbbc88)) 10 | 11 | 12 | ### Features 13 | 14 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 15 | * **take:** curry the external API ([ad05689](https://github.com/TylorS/tempest/commit/ad05689)) 16 | * **take:** implement take operator ([61933de](https://github.com/TylorS/tempest/commit/61933de)) 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /packages/take/dist/tempest-take.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestTake=global.tempestTake||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";var take=function(amount,stream){switch(arguments.length){case 1:return function(stream){return new _tempest_core.Stream(new Take(amount,stream.source))};case 2:return new _tempest_core.Stream(new Take(amount,stream.source));default:return take}};var Take=function Take(amount,source){this.amount=amount;this.source=source};Take.prototype.run=function run(sink,scheduler){return new TakeSink(this.amount,sink,this.source,scheduler)};var TakeSink=function TakeSink(amount,sink,source,scheduler){this.amount=amount;this.sink=sink;this.disposable=source.run(this,scheduler)};TakeSink.prototype.event=function event(time,value){if(--this.amount>=0){this.sink.event(time,value);if(this.amount===0){this.dispose();this.sink.end(time,value)}}};TakeSink.prototype.error=function error(time,err){this.sink.error(time,err)};TakeSink.prototype.end=function end(time,value){this.sink.end(time,value)};TakeSink.prototype.dispose=function dispose(){return this.disposable.dispose()};exports.take=take;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/take/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/take", 3 | "version": "1.2.0", 4 | "description": "take operator for tempest", 5 | "main": "dist/tempest-take.js", 6 | "jsnext:main": "lib/index.js", 7 | "typings": "lib/index.d.ts", 8 | "scripts": { 9 | "lint": "tslint -c ../../tslint.json src/*.ts src/**/*.ts", 10 | "unit-test": "mocha --compilers ts:espower-typescript/guess -r ts-node/register test/*.ts test/**/*.ts", 11 | "pretest": "typings install", 12 | "test": "npm run lint && npm run unit-test", 13 | "build:es2015": "../../node_modules/.bin/tsc --moduleResolution node --preserveConstEnums --sourceMap --declaration --noImplicitAny --suppressImplicitAnyIndexErrors --module es2015 --target es6 --outDir lib/ src/index.ts", 14 | "build:umd": "rollup -c", 15 | "build:minify": "uglifyjs dist/tempest-take.js -o dist/tempest-take.min.js", 16 | "build": "npm run build:es2015 && npm run build:umd && npm run build:minify", 17 | "prebuild": "rimraf lib dist && mkdirp dist lib && typings install" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/TylorS/tempest.git" 22 | }, 23 | "keywords": [ 24 | "tempest", 25 | "take", 26 | "stream", 27 | "reactive", 28 | "cycle.js", 29 | "cycle" 30 | ], 31 | "author": "Tylor Steinberger (github.com/TylorS)", 32 | "license": "MIT", 33 | "bugs": { 34 | "url": "https://github.com/TylorS/tempest/issues" 35 | }, 36 | "homepage": "https://github.com/TylorS/tempest#readme", 37 | "dependencies": { 38 | "@tempest/core": "^0.3.0" 39 | }, 40 | "devDependencies": { 41 | "espower-typescript": "^5.0.1", 42 | "mkdirp": "^0.5.1", 43 | "mocha": "^2.5.3", 44 | "power-assert": "^1.4.1", 45 | "rimraf": "^2.5.3", 46 | "rollup": "^0.34.1", 47 | "rollup-plugin-buble": "^0.12.1", 48 | "ts-node": "^0.9.3", 49 | "tslint": "^3.13.0", 50 | "typings": "^1.3.1", 51 | "uglify-js": "^2.7.0" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/take/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-take.js', 6 | format: 'umd', 7 | moduleName: 'tempestTake', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/take/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Scheduler, Disposable} from '@tempest/core' 2 | 3 | export interface TakeCurried { 4 | (): (amount: number, stream: Stream) => Stream 5 | (amount: number): (stream: Stream) => Stream 6 | (amount: number, stream: Stream): Stream 7 | } 8 | 9 | export const take: TakeCurried = function (amount: number, stream: Stream): Stream | 10 | ((stream: Stream) => Stream) | ((amount: number, stream: Stream) => Stream) { 11 | switch (arguments.length) { 12 | case 1: return function (stream: Stream) { return new Stream(new Take(amount, stream.source)) } 13 | case 2: return new Stream(new Take(amount, stream.source)) 14 | default: return take 15 | } 16 | } 17 | 18 | class Take implements Source { 19 | constructor (private amount: number, private source: Source) {} 20 | 21 | run (sink: Sink, scheduler: Scheduler): Disposable { 22 | return new TakeSink(this.amount, sink, this.source, scheduler) 23 | } 24 | } 25 | 26 | class TakeSink implements Sink, Disposable { 27 | private disposable: Disposable 28 | constructor (private amount: number, private sink: Sink, 29 | source: Source, scheduler: Scheduler) { 30 | this.disposable = source.run(this, scheduler) 31 | } 32 | 33 | event (time: number, value: T) { 34 | if (--this.amount >= 0) { 35 | this.sink.event(time, value) 36 | if (this.amount === 0) { 37 | this.dispose() 38 | this.sink.end(time, value) 39 | } 40 | } 41 | } 42 | 43 | error (time: number, err: Error) { 44 | this.sink.error(time, err) 45 | } 46 | 47 | end (time: number, value?: T) { 48 | this.sink.end(time, value) 49 | } 50 | 51 | dispose () { 52 | return this.disposable.dispose() 53 | } 54 | } -------------------------------------------------------------------------------- /packages/take/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { take } from '../src/index' 6 | 7 | describe('@tempest/take', () => { 8 | it ('should take n events and end', (done) => { 9 | const stream = take(1, Stream.of(1, 2, 3)) 10 | const expected = [1] 11 | 12 | stream.subscribe((x: number) => { 13 | assert(x === expected.shift()) 14 | }, done, () => done()) 15 | }) 16 | 17 | it ('should be curried', (done) => { 18 | const first = take(1) 19 | const stream = first(Stream.of(1, 2, 3)) 20 | const expected = [1] 21 | 22 | stream.subscribe((x: number) => { 23 | assert(x === expected.shift()) 24 | }, done, () => done()) 25 | }) 26 | }) -------------------------------------------------------------------------------- /packages/take/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/take/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/map", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/throwError/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## 1.1.2 (2016-08-03) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **map:** mapTo was defined twice ([41a18bd](https://github.com/TylorS/tempest/commit/41a18bd)) 8 | * **meta:** update dependencies to latest version of core ([b6c03b1](https://github.com/TylorS/tempest/commit/b6c03b1)) 9 | 10 | 11 | ### Features 12 | 13 | * **subject:** implement asSubject operator ([e07cc5e](https://github.com/TylorS/tempest/commit/e07cc5e)) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /packages/throwError/dist/tempest-throwError.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tempest/core')) : 3 | typeof define === 'function' && define.amd ? define(['exports', '@tempest/core'], factory) : 4 | (factory((global.tempestThrowError = global.tempestThrowError || {}),global.tempestCore)); 5 | }(this, function (exports,_tempest_core) { 'use strict'; 6 | 7 | function throwError(err) { 8 | return new _tempest_core.Stream(new ThrowError(err)); 9 | } 10 | var ThrowError = function ThrowError(err) { 11 | this.err = err; 12 | }; 13 | ThrowError.prototype.run = function run (sink, scheduler) { 14 | var task = scheduler.asap(_tempest_core.PropagateTask.error(this.err, sink)); 15 | return { 16 | dispose: function dispose() { 17 | scheduler.cancel(task); 18 | } 19 | }; 20 | }; 21 | 22 | exports.throwError = throwError; 23 | exports.ThrowError = ThrowError; 24 | 25 | Object.defineProperty(exports, '__esModule', { value: true }); 26 | 27 | })); 28 | //# sourceMappingURL=tempest-throwError.js.map 29 | -------------------------------------------------------------------------------- /packages/throwError/dist/tempest-throwError.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":null,"sources":["../lib/index.js"],"sourcesContent":["import { Stream, PropagateTask } from '@tempest/core';\nexport function throwError(err) {\n return new Stream(new ThrowError(err));\n}\nexport class ThrowError {\n constructor(err) {\n this.err = err;\n }\n run(sink, scheduler) {\n const task = scheduler.asap(PropagateTask.error(this.err, sink));\n return {\n dispose() {\n scheduler.cancel(task);\n }\n };\n }\n}\n//# sourceMappingURL=index.js.map"],"names":["Stream","PropagateTask"],"mappings":";;;;;;IACO,SAAS,UAAU,CAAC,GAAG,EAAE;QAC5B,OAAO,IAAIA,oBAAM,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;KAC1C;AACD,AAAO,IAAA,IAAM,UAAU,GAAC,mBACT,CAAC,GAAG,EAAE;QACjB,IAAQ,CAAC,GAAG,GAAG,GAAG,CAAC;AACvB,IAAA,CAAK,CAAA;AACL,IAAA,qBAAI,GAAG,iBAAC,IAAI,EAAE,SAAS,EAAE;QACrB,IAAU,IAAI,GAAG,SAAS,CAAC,IAAI,CAACC,2BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;QACrE,OAAW;YACP,OAAW,kBAAA,GAAG;gBACV,SAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAC1B;SACJ,CAAC;AACV,IAAA,CAAK,CAAA;;;;;;;"} -------------------------------------------------------------------------------- /packages/throwError/dist/tempest-throwError.min.js: -------------------------------------------------------------------------------- 1 | (function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports,require("@tempest/core")):typeof define==="function"&&define.amd?define(["exports","@tempest/core"],factory):factory(global.tempestThrowError=global.tempestThrowError||{},global.tempestCore)})(this,function(exports,_tempest_core){"use strict";function throwError(err){return new _tempest_core.Stream(new ThrowError(err))}var ThrowError=function ThrowError(err){this.err=err};ThrowError.prototype.run=function run(sink,scheduler){var task=scheduler.asap(_tempest_core.PropagateTask.error(this.err,sink));return{dispose:function dispose(){scheduler.cancel(task)}}};exports.throwError=throwError;exports.ThrowError=ThrowError;Object.defineProperty(exports,"__esModule",{value:true})}); -------------------------------------------------------------------------------- /packages/throwError/rollup.config.js: -------------------------------------------------------------------------------- 1 | import buble from 'rollup-plugin-buble' 2 | 3 | export default { 4 | entry: 'lib/index.js', 5 | dest: 'dist/tempest-throwError.js', 6 | format: 'umd', 7 | moduleName: 'tempestThrowError', 8 | sourceMap: true, 9 | globals: { 10 | '@tempest/core': 'tempestCore' 11 | }, 12 | plugins: [ 13 | buble() 14 | ] 15 | } -------------------------------------------------------------------------------- /packages/throwError/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Stream, Source, Sink, Disposable, Scheduler, PropagateTask } from '@tempest/core' 2 | 3 | export function throwError (err: Error): Stream { 4 | return new Stream(new ThrowError(err)) 5 | } 6 | 7 | export class ThrowError implements Source { 8 | constructor (private err: Error) {} 9 | 10 | run (sink: Sink, scheduler: Scheduler): Disposable { 11 | const task = scheduler.asap(PropagateTask.error(this.err, sink)) 12 | 13 | return { 14 | dispose () { 15 | scheduler.cancel(task) 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /packages/throwError/test/index.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | import * as assert from 'power-assert' 4 | import { Stream } from '@tempest/core' 5 | import { throwError } from '../src/index' 6 | 7 | describe('@tempest/throwError', () => { 8 | it ('should create an errored stream', (done) => { 9 | const err = new Error('error message') 10 | const stream = throwError(err) 11 | 12 | assert(stream instanceof Stream) 13 | 14 | stream.subscribe(done, (_err: Error) => { 15 | assert(_err === err) 16 | assert(_err.message === 'error message') 17 | done() 18 | }) 19 | }) 20 | }) -------------------------------------------------------------------------------- /packages/throwError/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "moduleResolution": "node", 4 | "removeComments": false, 5 | "preserveConstEnums": true, 6 | "sourceMap": true, 7 | "declaration": true, 8 | "noImplicitAny": true, 9 | "suppressImplicitAnyIndexErrors": true, 10 | "noEmitHelpers": false, 11 | "module": "commonjs", 12 | "target": "es6", 13 | "outDir": "./lib" 14 | }, 15 | "formatCodeOptions": { 16 | "indentSize": 2, 17 | "tabSize": 2 18 | }, 19 | "files": ["src/index.ts"], 20 | "filesGlob": [ 21 | "src/**/*.ts" 22 | ], 23 | "atom": { 24 | "rewriteTsconfig": true 25 | } 26 | } -------------------------------------------------------------------------------- /packages/throwError/typings.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tempest/throwError", 3 | "globalDevDependencies": { 4 | "empower": "registry:dt/empower#0.0.0+20160317120654", 5 | "mocha": "registry:dt/mocha#2.2.5+20160619032855", 6 | "node": "registry:dt/node#6.0.0+20160709114037", 7 | "power-assert": "registry:dt/power-assert#0.0.0+20160316155526", 8 | "power-assert-formatter": "registry:dt/power-assert-formatter#0.0.0+20160317120654" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "curly": false, 4 | "eofline": false, 5 | "align": [true, "parameters"], 6 | "class-name": true, 7 | "indent": [true, "spaces"], 8 | "max-line-length": [true, 150], 9 | "no-consecutive-blank-lines": true, 10 | "no-trailing-whitespace": true, 11 | "no-duplicate-key": true, 12 | "no-duplicate-variable": true, 13 | "no-unreachable": true, 14 | "no-var-keyword": true, 15 | "no-empty": true, 16 | "no-unused-expression": true, 17 | "no-unused-variable": true, 18 | "no-use-before-declare": true, 19 | "no-var-requires": false, 20 | "no-require-imports": false, 21 | "one-line": [true, 22 | "check-else", 23 | "check-whitespace", 24 | "check-open-brace"], 25 | "quotemark": [true, 26 | "single", 27 | "avoid-escape"], 28 | "semicolon": [false], 29 | "typedef-whitespace": [true, { 30 | "call-signature": "nospace", 31 | "index-signature": "nospace", 32 | "parameter": "nospace", 33 | "property-declaration": "nospace", 34 | "variable-declaration": "nospace" 35 | }], 36 | "whitespace": [true, 37 | "check-branch", 38 | "check-decl", 39 | "check-operator", 40 | "check-separator", 41 | "check-type"] 42 | } 43 | } --------------------------------------------------------------------------------