@sanity/observable
Advanced tools
Comparing version 2.0.1 to 2.0.9
{ | ||
"name": "@sanity/observable", | ||
"description": "[deprecated] This package exists for legacy reasons only", | ||
"version": "2.0.1", | ||
"version": "2.0.9", | ||
"main": "minimal.js", | ||
@@ -40,3 +40,3 @@ "types": "./minimal.d.ts", | ||
"homepage": "https://www.sanity.io/", | ||
"gitHead": "2513e0eb112a5994feaba4dc6ac5322f2e865c25" | ||
"gitHead": "d8995bef8b46f6844af90addc1e43204470999c1" | ||
} |
@@ -12,3 +12,3 @@ // const {create} = require('observable-props') | ||
static of(...args) { | ||
return new CustomObservable(observer => of(...args).subscribe(observer)) | ||
return new CustomObservable((observer) => of(...args).subscribe(observer)) | ||
} | ||
@@ -28,7 +28,7 @@ lift(operator) { | ||
mergeMap: mergeMap, | ||
switchMap: switchMap | ||
switchMap: switchMap, | ||
}) | ||
function fetchAsync(result) { | ||
return new CustomObservable(observer => { | ||
return new CustomObservable((observer) => { | ||
setTimeout(() => observer.next(result), 0) | ||
@@ -40,4 +40,4 @@ }) | ||
fetchAsync({ok: 1}) | ||
.switchMap(ok => CustomObservable.of(ok)) | ||
.map(notOk => notOk.nothere.fail) | ||
.subscribe(v => console.log(v)) | ||
.switchMap((ok) => CustomObservable.of(ok)) | ||
.map((notOk) => notOk.nothere.fail) | ||
.subscribe((v) => console.log(v)) |
@@ -10,4 +10,4 @@ /* eslint no-shadow: ["error", { "allow": ['t'] }] */ | ||
test('static properties', t => { | ||
const staticFields = staticProps.filter(key => typeof Observable[key] !== 'function') | ||
test('static properties', (t) => { | ||
const staticFields = staticProps.filter((key) => typeof Observable[key] !== 'function') | ||
t.ok( | ||
@@ -20,4 +20,4 @@ staticFields.length === 0, | ||
test('static methods', t => { | ||
const staticFunctions = staticProps.filter(key => typeof Observable[key] === 'function') | ||
test('static methods', (t) => { | ||
const staticFunctions = staticProps.filter((key) => typeof Observable[key] === 'function') | ||
t.same(staticFunctions, []) | ||
@@ -36,3 +36,3 @@ t.end() | ||
t.test('instance methods', t => { | ||
t.test('instance methods', (t) => { | ||
const instance = new Observable(() => {}) | ||
@@ -50,11 +50,19 @@ t.same(getInheritedAndOwnProperties(instance), [ | ||
'pipe', | ||
'toPromise' | ||
'toPromise', | ||
]) | ||
;['map', 'filter', 'reduce', 'toPromise', 'lift', 'pipe', 'subscribe', 'forEach'].forEach( | ||
method => | ||
t.type( | ||
instance[method], | ||
'function', | ||
`Expected observable instance to expose the method ${method}` | ||
) | ||
;[ | ||
'map', | ||
'filter', | ||
'reduce', | ||
'toPromise', | ||
'lift', | ||
'pipe', | ||
'subscribe', | ||
'forEach', | ||
].forEach((method) => | ||
t.type( | ||
instance[method], | ||
'function', | ||
`Expected observable instance to expose the method ${method}` | ||
) | ||
) | ||
@@ -68,5 +76,5 @@ | ||
test('Exposed api should not be affected by require("rxjs")', {autoend: true}, t => { | ||
test('Exposed api should not be affected by require("rxjs")', {autoend: true}, (t) => { | ||
require('rxjs') | ||
run(t) | ||
}) |
const {test} = require('tap') | ||
const Observable = require('../src/SanityObservableMinimal') | ||
test('it works', t => { | ||
new Observable(observer => { | ||
;['tiger', 'lion', 'SKIP', 'cheetah'].forEach(word => { | ||
test('it works', (t) => { | ||
new Observable((observer) => { | ||
;['tiger', 'lion', 'SKIP', 'cheetah'].forEach((word) => { | ||
observer.next(word) | ||
@@ -11,4 +11,4 @@ }) | ||
}) | ||
.filter(word => word !== 'SKIP') | ||
.map(word => word.toUpperCase()) | ||
.filter((word) => word !== 'SKIP') | ||
.map((word) => word.toUpperCase()) | ||
.reduce((wordLengths, word) => { | ||
@@ -18,3 +18,3 @@ wordLengths[word] = word.length | ||
}, {}) | ||
.subscribe(wordLengths => { | ||
.subscribe((wordLengths) => { | ||
t.same(wordLengths, {TIGER: 5, LION: 4, CHEETAH: 7}) | ||
@@ -21,0 +21,0 @@ t.end() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171
7983
12