From 75198fbebe6ef6ec52af7c11535e076aea269c36 Mon Sep 17 00:00:00 2001 From: Chris Cowan Date: Fri, 7 Jun 2019 18:17:09 -0700 Subject: [PATCH] Update prettier and re-prettify the world --- package-lock.json | 125 +------------------------------ package.json | 2 +- src/interop/symbol.js | 2 +- src/interop/to-es-observable.js | 7 +- src/many-sources/combine.js | 7 +- src/observable.js | 7 +- src/utils/collections.js | 36 ++++++--- src/utils/now.js | 2 +- src/utils/objects.js | 7 +- test/flow/combine.js | 14 ++-- test/flow/error.js | 5 +- test/specs/flat-map.js | 16 ++-- test/specs/from-callback.js | 4 +- test/specs/from-node-callback.js | 6 +- test/specs/kefir-observable.js | 2 +- test/specs/kefir-stream.js | 2 +- test/specs/log.js | 12 ++- test/specs/pool.js | 31 ++++++-- test/specs/repeat.js | 5 +- test/specs/spy.js | 12 ++- test/specs/to-property.js | 2 +- 21 files changed, 127 insertions(+), 179 deletions(-) diff --git a/package-lock.json b/package-lock.json index d8b2c831..cc3f095c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -98,12 +98,6 @@ "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, - "ast-types": { - "version": "0.9.8", - "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.9.8.tgz", - "integrity": "sha1-bLakC+ujH0nyCSjihDn8FKPasHg=", - "dev": true - }, "babel-code-frame": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", @@ -1535,12 +1529,6 @@ "integrity": "sha512-jcethhgrslBJukH7Z7883ohFFpzLrdsOEwHxvn5NwuTWbNaE71GAl55/PEBRJwYpDvYkRlqgcNkANTv0x5XjqA==", "dev": true }, - "flow-parser": { - "version": "0.43.0", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.43.0.tgz", - "integrity": "sha1-4rjrGsg91T97awSnw1tqUsM0ebc=", - "dev": true - }, "formatio": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.1.1.tgz", @@ -1574,12 +1562,6 @@ "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", "dev": true }, - "get-stdin": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz", - "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=", - "dev": true - }, "get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", @@ -1873,28 +1855,6 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, - "jest-matcher-utils": { - "version": "19.0.0", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-19.0.0.tgz", - "integrity": "sha1-Xs2bY1ZdKwAfYfv37Ex/U3lkVk0=", - "dev": true, - "requires": { - "chalk": "^1.1.3", - "pretty-format": "^19.0.0" - } - }, - "jest-validate": { - "version": "19.0.0", - "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-19.0.0.tgz", - "integrity": "sha1-jGMYog7P6roLpTeL+7gner3tQXM=", - "dev": true, - "requires": { - "chalk": "^1.1.1", - "jest-matcher-utils": "^19.0.0", - "leven": "^2.0.0", - "pretty-format": "^19.0.0" - } - }, "js-stringify": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz", @@ -1980,12 +1940,6 @@ "invert-kv": "^2.0.0" } }, - "leven": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", - "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=", - "dev": true - }, "locate-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", @@ -2398,81 +2352,10 @@ "dev": true }, "prettier": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.0.2.tgz", - "integrity": "sha1-hFNVSPygDPCs18qCltSSNS7xZ9c=", - "dev": true, - "requires": { - "ast-types": "0.9.8", - "babel-code-frame": "6.22.0", - "babylon": "7.0.0-beta.8", - "chalk": "1.1.3", - "esutils": "2.0.2", - "flow-parser": "0.43.0", - "get-stdin": "5.0.1", - "glob": "7.1.1", - "jest-validate": "19.0.0", - "minimist": "1.2.0" - }, - "dependencies": { - "babel-code-frame": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz", - "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=", - "dev": true, - "requires": { - "chalk": "^1.1.0", - "esutils": "^2.0.2", - "js-tokens": "^3.0.0" - } - }, - "babylon": { - "version": "7.0.0-beta.8", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.8.tgz", - "integrity": "sha1-K9xa42YEFELCfgaMzm8NfAbqmUk=", - "dev": true - }, - "glob": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.2", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } - } - }, - "pretty-format": { - "version": "19.0.0", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-19.0.0.tgz", - "integrity": "sha1-VlMNMqy5ij+khRxOK503tCBoTIQ=", - "dev": true, - "requires": { - "ansi-styles": "^3.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - } - } + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.18.2.tgz", + "integrity": "sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==", + "dev": true }, "private": { "version": "0.1.8", diff --git a/package.json b/package.json index 50f968ce..40a07925 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "flow-bin": "^0.100.0", "inquirer": "^6.3.1", "mocha": "^6.1.4", - "prettier": "1.0.2", + "prettier": "^1.18.2", "pug": "^2.0.3", "rollup": "^0.41.6", "rollup-plugin-babel": "^2.7.1", diff --git a/src/interop/symbol.js b/src/interop/symbol.js index b087144c..0020f294 100644 --- a/src/interop/symbol.js +++ b/src/interop/symbol.js @@ -1,4 +1,4 @@ // this file contains some hot JS modules systems stuff import symbol from 'symbol-observable' -export default (symbol.default ? symbol.default : symbol) +export default symbol.default ? symbol.default : symbol diff --git a/src/interop/to-es-observable.js b/src/interop/to-es-observable.js index bab3c90f..16fa6873 100644 --- a/src/interop/to-es-observable.js +++ b/src/interop/to-es-observable.js @@ -8,9 +8,10 @@ function ESObservable(observable) { extend(ESObservable.prototype, { subscribe(observerOrOnNext, onError, onComplete) { - const observer = typeof observerOrOnNext === 'function' - ? {next: observerOrOnNext, error: onError, complete: onComplete} - : observerOrOnNext + const observer = + typeof observerOrOnNext === 'function' + ? {next: observerOrOnNext, error: onError, complete: onComplete} + : observerOrOnNext const fn = event => { if (event.type === END) { diff --git a/src/many-sources/combine.js b/src/many-sources/combine.js index 3232139d..7b67296e 100644 --- a/src/many-sources/combine.js +++ b/src/many-sources/combine.js @@ -70,7 +70,8 @@ inherit(Combine, Stream, { }, _onDeactivation() { - let length = this._sources.length, i + let length = this._sources.length, + i for (i = 0; i < length; i++) { this._sources[i].offAny(this._$handlers[i]) } @@ -166,7 +167,9 @@ function combineAsObject(active, passive = {}, combinator) { throw new Error('Combine can only combine active and passive collections of the same type.') } - let keys = [], activeObservables = [], passiveObservables = [] + let keys = [], + activeObservables = [], + passiveObservables = [] collect(active, keys, activeObservables) collect(passive, keys, passiveObservables) diff --git a/src/observable.js b/src/observable.js index b91ea5e6..677d152e 100644 --- a/src/observable.js +++ b/src/observable.js @@ -119,9 +119,10 @@ extend(Observable.prototype, { const _this = this let closed = false - const observer = !observerOrOnValue || typeof observerOrOnValue === 'function' - ? {value: observerOrOnValue, error: onError, end: onEnd} - : observerOrOnValue + const observer = + !observerOrOnValue || typeof observerOrOnValue === 'function' + ? {value: observerOrOnValue, error: onError, end: onEnd} + : observerOrOnValue const handler = function(event) { if (event.type === END) { diff --git a/src/utils/collections.js b/src/utils/collections.js index a36f16d5..14e60807 100644 --- a/src/utils/collections.js +++ b/src/utils/collections.js @@ -20,7 +20,9 @@ function concat(a, b) { } function circleShift(arr, distance) { - let length = arr.length, result = new Array(length), i + let length = arr.length, + result = new Array(length), + i for (i = 0; i < length; i++) { result[(i + distance) % length] = arr[i] } @@ -28,7 +30,8 @@ function circleShift(arr, distance) { } function find(arr, value) { - let length = arr.length, i + let length = arr.length, + i for (i = 0; i < length; i++) { if (arr[i] === value) { return i @@ -38,7 +41,8 @@ function find(arr, value) { } function findByPred(arr, pred) { - let length = arr.length, i + let length = arr.length, + i for (i = 0; i < length; i++) { if (pred(arr[i])) { return i @@ -48,7 +52,9 @@ function findByPred(arr, pred) { } function cloneArray(input) { - let length = input.length, result = new Array(length), i + let length = input.length, + result = new Array(length), + i for (i = 0; i < length; i++) { result[i] = input[i] } @@ -56,13 +62,16 @@ function cloneArray(input) { } function remove(input, index) { - let length = input.length, result, i, j + let length = input.length, + result, + i, + j if (index >= 0 && index < length) { if (length === 1) { return [] } else { result = new Array(length - 1) - for ((i = 0), (j = 0); i < length; i++) { + for (i = 0, j = 0; i < length; i++) { if (i !== index) { result[j] = input[i] j++ @@ -80,7 +89,9 @@ function removeByPred(input, pred) { } function map(input, fn) { - let length = input.length, result = new Array(length), i + let length = input.length, + result = new Array(length), + i for (i = 0; i < length; i++) { result[i] = fn(input[i]) } @@ -88,14 +99,16 @@ function map(input, fn) { } function forEach(arr, fn) { - let length = arr.length, i + let length = arr.length, + i for (i = 0; i < length; i++) { fn(arr[i]) } } function fillArray(arr, value) { - let length = arr.length, i + let length = arr.length, + i for (i = 0; i < length; i++) { arr[i] = value } @@ -106,7 +119,10 @@ function contains(arr, value) { } function slide(cur, next, max) { - let length = Math.min(max, cur.length + 1), offset = cur.length - length + 1, result = new Array(length), i + let length = Math.min(max, cur.length + 1), + offset = cur.length - length + 1, + result = new Array(length), + i for (i = offset; i < length; i++) { result[i - offset] = cur[i] } diff --git a/src/utils/now.js b/src/utils/now.js index a6b6d60a..edb5b1c6 100644 --- a/src/utils/now.js +++ b/src/utils/now.js @@ -1 +1 @@ -export default (Date.now ? () => Date.now() : () => new Date().getTime()) +export default Date.now ? () => Date.now() : () => new Date().getTime() diff --git a/src/utils/objects.js b/src/utils/objects.js index 687fabac..abf3066a 100644 --- a/src/utils/objects.js +++ b/src/utils/objects.js @@ -5,7 +5,9 @@ function createObj(proto) { } function extend(target /*, mixin1, mixin2...*/) { - let length = arguments.length, i, prop + let length = arguments.length, + i, + prop for (i = 1; i < length; i++) { for (prop in arguments[i]) { target[prop] = arguments[i][prop] @@ -15,7 +17,8 @@ function extend(target /*, mixin1, mixin2...*/) { } function inherit(Child, Parent /*, mixin1, mixin2...*/) { - let length = arguments.length, i + let length = arguments.length, + i Child.prototype = createObj(Parent.prototype) Child.prototype.constructor = Child for (i = 2; i < length; i++) { diff --git a/test/flow/combine.js b/test/flow/combine.js index e891a68d..11f3af23 100644 --- a/test/flow/combine.js +++ b/test/flow/combine.js @@ -124,13 +124,13 @@ function test_combine_object_withCombinator() { } function test_combine_object_withCombinatorAndPassive() { - const xs = Kefir.combine({numbers, strings}, {functions}, (args: { - numbers: number, - strings: string, - functions: (n: number) => string, - }) => { - return args.functions(args.numbers) + args.strings - }) + const xs = Kefir.combine( + {numbers, strings}, + {functions}, + (args: {numbers: number, strings: string, functions: (n: number) => string}) => { + return args.functions(args.numbers) + args.strings + } + ) xs.onValue((x: string) => {}) diff --git a/test/flow/error.js b/test/flow/error.js index 0245ab22..3be6f9ad 100644 --- a/test/flow/error.js +++ b/test/flow/error.js @@ -3,7 +3,10 @@ import Kefir from '../../kefir' // error type should be persisted through and unaffected by map call. -const prop = Kefir.constantError(1).merge(Kefir.constant(2)).map(x => String(x)).mapErrors(err => ({a: err})) +const prop = Kefir.constantError(1) + .merge(Kefir.constant(2)) + .map(x => String(x)) + .mapErrors(err => ({a: err})) prop .onValue(x => { diff --git a/test/specs/flat-map.js b/test/specs/flat-map.js index 89cee594..b765e774 100644 --- a/test/specs/flat-map.js +++ b/test/specs/flat-map.js @@ -121,7 +121,9 @@ describe('flatMap', () => { return () => unsubs++ }) - const b = Kefir.constant(1).flatMap(() => a).take(1) + const b = Kefir.constant(1) + .flatMap(() => a) + .take(1) b.onValue(() => {}) @@ -131,11 +133,13 @@ describe('flatMap', () => { it('should not error when source ends in response to synchronous value', () => { const src = stream() - const result = src.flatMap(x => Kefir.constant(x)).onValue(x => { - if (x === 1) { - send(src, [end()]) - } - }) + const result = src + .flatMap(x => Kefir.constant(x)) + .onValue(x => { + if (x === 1) { + send(src, [end()]) + } + }) expect(result).to.emit([end()], () => { send(src, [value(1)]) }) diff --git a/test/specs/from-callback.js b/test/specs/from-callback.js index b4f2a199..6a75de57 100644 --- a/test/specs/from-callback.js +++ b/test/specs/from-callback.js @@ -24,12 +24,12 @@ describe('fromCallback', () => { it('should emit first result and end after that', () => { let cb = null - expect(Kefir.fromCallback(_cb => cb = _cb)).to.emit([value(1), end()], () => cb(1)) + expect(Kefir.fromCallback(_cb => (cb = _cb))).to.emit([value(1), end()], () => cb(1)) }) it('should work after deactivation/activate cicle', () => { let cb = null - const s = Kefir.fromCallback(_cb => cb = _cb) + const s = Kefir.fromCallback(_cb => (cb = _cb)) activate(s) deactivate(s) activate(s) diff --git a/test/specs/from-node-callback.js b/test/specs/from-node-callback.js index 2ce303fd..afb3d16c 100644 --- a/test/specs/from-node-callback.js +++ b/test/specs/from-node-callback.js @@ -24,17 +24,17 @@ describe('fromNodeCallback', () => { it('should emit first result and end after that', () => { let cb = null - expect(Kefir.fromNodeCallback(_cb => cb = _cb)).to.emit([value(1), end()], () => cb(null, 1)) + expect(Kefir.fromNodeCallback(_cb => (cb = _cb))).to.emit([value(1), end()], () => cb(null, 1)) }) it('should emit first error and end after that', () => { let cb = null - expect(Kefir.fromNodeCallback(_cb => cb = _cb)).to.emit([error(-1), end()], () => cb(-1)) + expect(Kefir.fromNodeCallback(_cb => (cb = _cb))).to.emit([error(-1), end()], () => cb(-1)) }) it('should work after deactivation/activate cicle', () => { let cb = null - const s = Kefir.fromNodeCallback(_cb => cb = _cb) + const s = Kefir.fromNodeCallback(_cb => (cb = _cb)) activate(s) deactivate(s) activate(s) diff --git a/test/specs/kefir-observable.js b/test/specs/kefir-observable.js index 5761c584..4519b177 100644 --- a/test/specs/kefir-observable.js +++ b/test/specs/kefir-observable.js @@ -10,7 +10,7 @@ describe('Kefir.Observable', () => { obs = Kefir.stream(_em => { em = _em }) - sub = obs.observe({value: () => count++, error: () => count--, end: () => count = 0}) + sub = obs.observe({value: () => count++, error: () => count--, end: () => (count = 0)}) }) it('should return a Subscription', () => { diff --git a/test/specs/kefir-stream.js b/test/specs/kefir-stream.js index 504902ca..5d821276 100644 --- a/test/specs/kefir-stream.js +++ b/test/specs/kefir-stream.js @@ -127,7 +127,7 @@ describe('Kefir.stream', () => { it('emitter should return a boolean representing if anyone intrested in future events', () => { let emitter = null - let a = Kefir.stream(em => emitter = em) + let a = Kefir.stream(em => (emitter = em)) activate(a) expect(emitter.value(1)).to.equal(true) deactivate(a) diff --git a/test/specs/log.js b/test/specs/log.js index ee86751c..db8bfa35 100644 --- a/test/specs/log.js +++ b/test/specs/log.js @@ -15,18 +15,24 @@ describe('log', () => { describe('removing', () => { it('should return the stream', () => { - expect(stream().log().offLog()).to.be.observable.stream() + expect( + stream() + .log() + .offLog() + ).to.be.observable.stream() }) it('should deactivate the stream', () => { - const a = stream().log().offLog() + const a = stream() + .log() + .offLog() expect(a).not.to.be.active() }) }) describe('console', () => { let stub - beforeEach(() => stub = sinon.stub(console, 'log')) + beforeEach(() => (stub = sinon.stub(console, 'log'))) afterEach(() => stub.restore()) diff --git a/test/specs/pool.js b/test/specs/pool.js index 740f57b5..7ac73417 100644 --- a/test/specs/pool.js +++ b/test/specs/pool.js @@ -15,7 +15,10 @@ describe('pool', () => { const a = stream() const b = prop() const c = stream() - const pool = Kefir.pool().plug(a).plug(b).plug(c) + const pool = Kefir.pool() + .plug(a) + .plug(b) + .plug(c) expect(pool).to.activate(a, b, c) pool.unplug(b) expect(pool).to.activate(a, c) @@ -26,7 +29,10 @@ describe('pool', () => { const a = stream() const b = send(prop(), [value(0)]) const c = stream() - const pool = Kefir.pool().plug(a).plug(b).plug(c) + const pool = Kefir.pool() + .plug(a) + .plug(b) + .plug(c) expect(pool).to.emit( [value(0, {current: true}), value(1), value(2), value(3), value(4), value(5), value(6)], () => { @@ -45,14 +51,23 @@ describe('pool', () => { const b = send(prop(), [value(1)]) const c = send(prop(), [value(2)]) - let pool = Kefir.pool().plug(a).plug(b).plug(c) + let pool = Kefir.pool() + .plug(a) + .plug(b) + .plug(c) expect(pool).to.emit([value(0, {current: true}), value(1, {current: true}), value(2, {current: true})]) - pool = Kefir.pool().plug(a).plug(b).plug(c) + pool = Kefir.pool() + .plug(a) + .plug(b) + .plug(c) activate(pool) expect(pool).to.emit([]) - pool = Kefir.pool().plug(a).plug(b).plug(c) + pool = Kefir.pool() + .plug(a) + .plug(b) + .plug(c) activate(pool) deactivate(pool) expect(pool).to.emit([value(0, {current: true}), value(1, {current: true}), value(2, {current: true})]) @@ -62,7 +77,11 @@ describe('pool', () => { const a = stream() const b = send(prop(), [value(0)]) const c = stream() - const pool = Kefir.pool().plug(a).plug(b).plug(c).unplug(b) + const pool = Kefir.pool() + .plug(a) + .plug(b) + .plug(c) + .unplug(b) expect(pool).to.emit([value(1), value(3), value(5), value(6)], () => { send(a, [value(1)]) send(b, [value(2)]) diff --git a/test/specs/repeat.js b/test/specs/repeat.js index c0040f7b..05124102 100644 --- a/test/specs/repeat.js +++ b/test/specs/repeat.js @@ -37,7 +37,10 @@ describe('repeat', () => { const sum = (a, b) => a + b const genConstant = () => Kefir.constant(1) - const a = Kefir.repeat(genConstant).take(3000).scan(sum, 0).last() + const a = Kefir.repeat(genConstant) + .take(3000) + .scan(sum, 0) + .last() expect(a).to.emit([value(3000, {current: true}), end({current: true})]) }) diff --git a/test/specs/spy.js b/test/specs/spy.js index 71a1862e..78f029d2 100644 --- a/test/specs/spy.js +++ b/test/specs/spy.js @@ -15,18 +15,24 @@ describe('spy', () => { describe('removing', () => { it('should return the stream', () => { - expect(stream().spy().offSpy()).to.be.observable.stream() + expect( + stream() + .spy() + .offSpy() + ).to.be.observable.stream() }) it('should not activate the stream', () => { - const a = stream().spy().offSpy() + const a = stream() + .spy() + .offSpy() expect(a).not.to.be.active() }) }) describe('console', () => { let stub - beforeEach(() => stub = sinon.stub(console, 'log')) + beforeEach(() => (stub = sinon.stub(console, 'log'))) afterEach(() => stub.restore()) diff --git a/test/specs/to-property.js b/test/specs/to-property.js index 62610845..783d35d1 100644 --- a/test/specs/to-property.js +++ b/test/specs/to-property.js @@ -42,7 +42,7 @@ describe('toProperty', () => { it('should reset value by getting new from the callback on each activation', () => { const getCurrent = p => { let result = null - const getter = x => result = x + const getter = x => (result = x) p.onValue(getter) p.offValue(getter) return result