@fullstax/kaplan-meier-estimator
Advanced tools
Comparing version 2.1.0 to 3.0.0
@@ -1,5 +0,1 @@ | ||
export interface KaplanMeierEsimatorData { | ||
tte: number; | ||
ev: boolean; | ||
} | ||
export interface KaplanMeierEsimatorResult { | ||
@@ -11,31 +7,2 @@ rate: number; | ||
/** | ||
* @interface KaplanMeierLodashHelpers | ||
* | ||
* This interface is used as the parameters for the init funktion. | ||
* This is a leftover from the original implementation and will be removed in the future. | ||
* | ||
* @deprecated | ||
*/ | ||
interface KaplanMeierLodashHelpers { | ||
pluck?: unknown; | ||
uniq?: unknown; | ||
sortBy?: unknown; | ||
groupBy?: unknown; | ||
last?: unknown; | ||
find?: unknown; | ||
} | ||
/** | ||
* This init function is a leftover from the original implementation | ||
* inthe "kaplan-meier" library and will be removed in the future. | ||
* | ||
* @deprecated | ||
* | ||
* @export | ||
* @param {KaplanMeierLodashHelpers} [lodashFunctions] | ||
* @returns | ||
*/ | ||
export declare function init(lodashFunctions?: KaplanMeierLodashHelpers): { | ||
compute: typeof compute; | ||
}; | ||
/** | ||
* @see http://en.wikipedia.org/wiki/Kaplan%E2%80%93Meier_estimator | ||
@@ -49,2 +16,1 @@ * | ||
export declare function compute(ttes: number[], events: boolean[]): KaplanMeierEsimatorResult[]; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KME={})}(this,(function(e){"use strict";function t(e,t){var n,r,u,o=(n=e.map((function(e,n){return{tte:e,ev:t[n]}})),r="tte",n.sort((function(e,t){return e[r]-t[r]}))),i=(u=e,Array.from(new Set(u))),f=function(e,t){return e.reduce((function(e,n){var r=t(n);return e[r]||(e[r]=[]),e[r].push(n),e}),{})}(o,(function(e){return e.tte})),s={n:o.length,e:0},c=i.reduce((function(e,t){var n=f[t],r=e.length?e[e.length-1]:s,u=n.filter((function(e){return e.ev})),o=r.n-r.e;return e.push({n:o,e:n.length,d:u.length,t:n[0].tte}),e}),[]);return c}function n(e,n){if(e.length!==n.length)throw new Error("[kaplan-meier-esimator]: events and censors must be of same length");var r=t(e,n),u={s:1,t:0};return r.reduce((function(e,t){var n=e.length?e[e.length-1]:u;return t.d?e.push({t:t.t||0,e:!0,s:n.s*(1-t.d/t.n),n:t.n,d:t.d,rate:t.d/t.n}):e.push({t:t.t||0,e:!1,s:n.s,n:t.n,d:t.d,rate:null}),e}),[]).map((function(e){return{rate:e.s,time:e.t,event:e.e||!1}}))}e.compute=n,e.init=function(e){return console.warn('[kaplan-meier-estimator] the "init" function is deprecated. It will be remove in the future!'),{compute:n}},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KME={})}(this,(function(e){"use strict";function t(e,t){const n=(r=e.map(((e,n)=>({tte:e,ev:t[n]}))),o="tte",r.sort(((e,t)=>e[o]-t[o])));var r,o;const s=(u=e,Array.from(new Set(u)));var u;const d=function(e,t){return e.reduce(((e,n)=>{const r=t(n);return e[r]||(e[r]=[]),e[r].push(n),e}),{})}(n,(e=>e.tte)),l={n:n.length,e:0},c=s.reduce(((e,t)=>{const n=d[t],r=e.length?e[e.length-1]:l,o=n.filter((e=>e.ev)),s=r.n-r.e;return e.push({n:s,e:n.length,d:o.length,t:n[0].tte}),e}),[]);return c}e.compute=function(e,n){if(e.length!==n.length)throw new Error("[kaplan-meier-esimator]: events and censors must be of same length");const r=t(e,n),o={s:1,t:0};return r.reduce(((e,t)=>{const n=e.length?e[e.length-1]:o;return t.d?e.push({t:t.t||0,e:!0,s:n.s*(1-t.d/t.n),n:t.n,d:t.d,rate:t.d/t.n}):e.push({t:t.t||0,e:!1,s:n.s,n:t.n,d:t.d,rate:null}),e}),[]).map((e=>({rate:e.s,time:e.t,event:e.e||!1})))},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=kaplan-meier-estimator.umd.js.map |
{ | ||
"name": "@fullstax/kaplan-meier-estimator", | ||
"description": "Kaplan-Meier-Estimator also known as the product limit estimator.", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"author": "fullstax Gmbh & Co. KG <dev@fullstax.de>", | ||
@@ -18,6 +18,6 @@ "contributors": [ | ||
"type": "module", | ||
"module": "lib/index.mjs", | ||
"types": "lib/index.d.ts", | ||
"main": "lib/kaplan-meier-estimator.cjs", | ||
"browser": "lib/kaplan-meier-estimator.umd.js", | ||
"module": "./lib/index.mjs", | ||
"types": "./lib/index.d.ts", | ||
"main": "./lib/kaplan-meier-estimator.cjs", | ||
"browser": "./lib/kaplan-meier-estimator.umd.js", | ||
"files": [ | ||
@@ -69,2 +69,3 @@ "lib/**/*", | ||
"prettier": "^2.6.2", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.73.0", | ||
@@ -71,0 +72,0 @@ "rollup-plugin-terser": "^7.0.2", |
@@ -5,4 +5,2 @@ # kaplan-meier-estimator | ||
This library implements the `init` and `compute` functions from the [kaplan-meier](https://www.npmjs.com/package/kaplan-meier) library and is therefore a modern "plug-in" replacement. | ||
## Installation | ||
@@ -24,4 +22,2 @@ | ||
To be compatible with the [kaplan-meier](https://www.npmjs.com/package/kaplan-meier) package we also provide an `init()` function, that does nothing. No external lodash/underscore functions are needed! This `init` function is deprecated and will be removed in the future (better not use it anymore!). | ||
### esm/typescript usage | ||
@@ -32,3 +28,3 @@ | ||
```ts | ||
import { compute } from 'kaplan-meier-estimator'; | ||
import { compute } from '@fullstax/kaplan-meier-estimator'; | ||
@@ -45,3 +41,3 @@ const timeToEvents = [1, 12, 22, 29, 31, …]; | ||
```js | ||
const { compute } = require('kaplan-meier-estimator/lib/kaplan-meier-estimator.cjs'; | ||
const { compute } = require('@fullstax/kaplan-meier-estimator'); | ||
``` | ||
@@ -53,2 +49,6 @@ | ||
```html | ||
<script src="https://unpkg.com/@fullstax/kaplan-meier-estimator/lib/kaplan-meier-estimator.umd.js"> | ||
``` | ||
```javascript | ||
@@ -55,0 +55,0 @@ const timeToEvents = [1, 12, 22, 29, 31, …]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
18022
22
320