zen-observable-ts
Advanced tools
Comparing version 1.0.0-beta.4 to 1.0.0-beta.5
@@ -5,1 +5,2 @@ import Observable = require("zen-observable"); | ||
export type Subscription = ZenObservable.Subscription; | ||
export type Subscriber<T> = ZenObservable.Subscriber<T>; |
@@ -1,1 +0,29 @@ | ||
export { Observable } from "zen-observable/esm.js"; | ||
import { Observable } from "zen-observable/esm.js"; | ||
// When a non-native class constructor function attempts to subclass | ||
// Observable, compilers like Babel and TypeScript may compile the | ||
// super(subscriber) expression to Observable.call(this, subscriber) or | ||
// Observable.apply(this, arguments). Calling a native class constructor | ||
// in this way is forbidden by the ECMAScript specification, but we can | ||
// preserve backwards compatibility by overriding the Observable.call and | ||
// Observable.apply methods with an implementation that calls | ||
// Reflect.construct instead, when available. | ||
Observable.call = function (instance, subscriber) { | ||
// Since Observable.call is a static method, 'this' will typically be the | ||
// Observable constructor function, though it could be a subclass of the | ||
// Observable constructor, which is why we don't just hard-code it here. | ||
return construct(this, instance, subscriber); | ||
}; | ||
Observable.apply = function (instance, args) { | ||
return construct(this, instance, args[0]); | ||
}; | ||
function construct(Super, instance, subscriber) { | ||
return typeof Reflect === 'object' | ||
? Reflect.construct(Super, [subscriber], instance.constructor) | ||
: Function.prototype.call.call(Super, instance, subscriber) || instance; | ||
} | ||
export { Observable } |
{ | ||
"name": "zen-observable-ts", | ||
"version": "1.0.0-beta.4", | ||
"version": "1.0.0-beta.5", | ||
"description": "Thin wrapper around zen-observable and @types/zen-observable, to support ESM exports as well as CommonJS exports", | ||
@@ -16,6 +16,22 @@ "license": "MIT", | ||
}, | ||
"scripts": { | ||
"pretest": "rollup -c rollup.config.js", | ||
"test": "mocha tests/bundle.js" | ||
}, | ||
"dependencies": { | ||
"@types/zen-observable": "^0.8.2", | ||
"zen-observable": "^0.8.15" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "^11.1.1", | ||
"@rollup/plugin-typescript": "^8.1.1", | ||
"@types/chai": "^4.2.14", | ||
"@types/mocha": "^8.2.0", | ||
"@types/node": "^14.14.22", | ||
"chai": "^4.2.0", | ||
"mocha": "^8.2.1", | ||
"rollup": "^2.38.4", | ||
"tslib": "^2.1.0", | ||
"typescript": "^4.1.3" | ||
} | ||
} |
# zen-observable-ts | ||
Thin wrapper around [`zen-observable`](https://www.npmjs.com/package/zen-observable) and [`@types/zen-observable`](https://www.npmjs.com/package/@types/zen-observable), to support ESM exports as well as CommonJS exports. | ||
Thin wrapper around [`zen-observable`](https://www.npmjs.com/package/zen-observable) and [`@types/zen-observable`](https://www.npmjs.com/package/@types/zen-observable), to support ESM exports as well as CommonJS exports, with TypeScript types provided by `@types/zen-observable`. | ||
@@ -12,1 +12,9 @@ ## Usage | ||
Note that this package does not currently have a default export, so the `{}` braces are mandatory. | ||
## Previous versions | ||
This tiny wrapper package replaces [an older version of `zen-observable-ts`](https://github.com/apollographql/apollo-link/tree/master/packages/zen-observable-ts) that used to provide TypeScript types for `zen-observable`, before `@types/zen-observable` was introduced. This version of the package is not intended to be perfectly compatible with the older version, so we have bumped the major version of the package to reflect the difference. | ||
## Future plans | ||
As explained in https://github.com/apollographql/apollo-client/pull/7615, the `zen-observable-ts` package exists to fill a gap in the functionality of the `zen-observable` package, so we will retire this package in favor of using `zen-observable` directly, when/if [this PR](https://github.com/zenparsing/zen-observable/pull/74) is ever merged. |
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
6334
9
31
1
20
0
10