Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fsrs.js

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fsrs.js - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

2

dist/fsrs.js.cjs.development.js

@@ -200,2 +200,4 @@ 'use strict';

exports.FSRS = FSRS;
exports.ReviewLog = ReviewLog;
exports.SchedulingInfo = SchedulingInfo;
//# sourceMappingURL=fsrs.js.cjs.development.js.map

2

dist/fsrs.js.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";function t(){return(t=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t}).apply(this,arguments)}var e,i;Object.defineProperty(exports,"__esModule",{value:!0}),(e=exports.State||(exports.State={}))[e.New=0]="New",e[e.Learning=1]="Learning",e[e.Review=2]="Review",e[e.Relearning=3]="Relearning",(i=exports.Rating||(exports.Rating={}))[i.Again=1]="Again",i[i.Hard=2]="Hard",i[i.Good=3]="Good",i[i.Easy=4]="Easy";var a=function(t,e,i,a,s){this.rating=t,this.elapsed_days=i,this.scheduled_days=e,this.review=a,this.state=s},s=function(t,e){this.card=t,this.review_log=e},n=function(){function e(e){this.again=t({},e),this.hard=t({},e),this.good=t({},e),this.easy=t({},e)}var i=e.prototype;return i.update_state=function(t){t===exports.State.New?(this.again.state=exports.State.Learning,this.hard.state=exports.State.Learning,this.good.state=exports.State.Learning,this.easy.state=exports.State.Review):t===exports.State.Learning||t===exports.State.Relearning?(this.again.state=t,this.hard.state=t,this.good.state=exports.State.Review,this.easy.state=exports.State.Review):t===exports.State.Review&&(this.again.state=exports.State.Relearning,this.hard.state=exports.State.Review,this.good.state=exports.State.Review,this.easy.state=exports.State.Review,this.again.lapses+=1)},i.schedule=function(t,e,i,a){this.again.scheduled_days=0,this.hard.scheduled_days=e,this.good.scheduled_days=i,this.easy.scheduled_days=a,this.again.due=new Date(t.getTime()+3e5),this.hard.due=e>0?new Date(t.getTime()+24*e*60*60*1e3):new Date(t.getTime()+6e5),this.good.due=new Date(t.getTime()+24*i*60*60*1e3),this.easy.due=new Date(t.getTime()+24*a*60*60*1e3)},i.record_log=function(t,e){var i;return(i={})[exports.Rating.Again]=new s(this.again,new a(exports.Rating.Again,this.again.scheduled_days,t.elapsed_days,e,t.state)),i[exports.Rating.Hard]=new s(this.hard,new a(exports.Rating.Hard,this.hard.scheduled_days,t.elapsed_days,e,t.state)),i[exports.Rating.Good]=new s(this.good,new a(exports.Rating.Good,this.good.scheduled_days,t.elapsed_days,e,t.state)),i[exports.Rating.Easy]=new s(this.easy,new a(exports.Rating.Easy,this.easy.scheduled_days,t.elapsed_days,e,t.state)),i},e}(),r=function(){this.request_retention=.9,this.maximum_interval=36500,this.w=[.4,.6,2.4,5.8,4.93,.94,.86,.01,1.49,.14,.94,2.18,.05,.34,1.26,.29,2.61]},o=function(){function e(){this.p=new r}var i=e.prototype;return i.repeat=function(e,i){(e=t({},e)).elapsed_days=e.state===exports.State.New?0:(i.getTime()-e.last_review.getTime())/864e5,e.last_review=i,e.reps+=1;var a=new n(e);if(a.update_state(e.state),e.state===exports.State.New){this.init_ds(a),a.again.due=new Date(i.getTime()+6e4),a.hard.due=new Date(i.getTime()+3e5),a.good.due=new Date(i.getTime()+6e5);var s=this.next_interval(a.easy.stability);a.easy.scheduled_days=s,a.easy.due=new Date(i.getTime()+24*s*60*60*1e3)}else if(e.state===exports.State.Learning||e.state===exports.State.Relearning){var r=this.next_interval(a.good.stability),o=Math.max(this.next_interval(a.easy.stability),r+1);a.schedule(i,0,r,o)}else if(e.state===exports.State.Review){var h=e.difficulty,d=e.stability,l=Math.pow(1+e.elapsed_days/(9*d),-1);this.next_ds(a,h,d,l);var p=this.next_interval(a.hard.stability),y=this.next_interval(a.good.stability);p=Math.min(p,y),y=Math.max(y,p+1);var g=Math.max(this.next_interval(a.easy.stability),y+1);a.schedule(i,p,y,g)}return a.record_log(e,i)},i.init_ds=function(t){t.again.difficulty=this.init_difficulty(exports.Rating.Again),t.again.stability=this.init_stability(exports.Rating.Again),t.hard.difficulty=this.init_difficulty(exports.Rating.Hard),t.hard.stability=this.init_stability(exports.Rating.Hard),t.good.difficulty=this.init_difficulty(exports.Rating.Good),t.good.stability=this.init_stability(exports.Rating.Good),t.easy.difficulty=this.init_difficulty(exports.Rating.Easy),t.easy.stability=this.init_stability(exports.Rating.Easy)},i.next_ds=function(t,e,i,a){t.again.difficulty=this.next_difficulty(e,exports.Rating.Again),t.again.stability=this.next_forget_stability(e,i,a),t.hard.difficulty=this.next_difficulty(e,exports.Rating.Hard),t.hard.stability=this.next_recall_stability(e,i,a,exports.Rating.Hard),t.good.difficulty=this.next_difficulty(e,exports.Rating.Good),t.good.stability=this.next_recall_stability(e,i,a,exports.Rating.Good),t.easy.difficulty=this.next_difficulty(e,exports.Rating.Easy),t.easy.stability=this.next_recall_stability(e,i,a,exports.Rating.Easy)},i.init_stability=function(t){return Math.max(this.p.w[t-1],.1)},i.init_difficulty=function(t){return Math.min(Math.max(this.p.w[4]-this.p.w[5]*(t-3),1),10)},i.next_interval=function(t){return Math.min(Math.max(Math.round(9*t*(1/this.p.request_retention-1)),1),this.p.maximum_interval)},i.next_difficulty=function(t,e){return Math.min(Math.max(this.mean_reversion(this.p.w[4],t-this.p.w[6]*(e-3)),1),10)},i.mean_reversion=function(t,e){return this.p.w[7]*t+(1-this.p.w[7])*e},i.next_recall_stability=function(t,e,i,a){var s=a===exports.Rating.Hard?this.p.w[15]:1,n=a===exports.Rating.Easy?this.p.w[16]:1;return e*(1+Math.exp(this.p.w[8])*(11-t)*Math.pow(e,-this.p.w[9])*(Math.exp((1-i)*this.p.w[10])-1)*s*n)},i.next_forget_stability=function(t,e,i){return this.p.w[11]*Math.pow(t,-this.p.w[12])*(Math.pow(e+1,this.p.w[13])-1)*Math.exp((1-i)*this.p.w[14])},e}();exports.Card=function(){this.due=new Date,this.stability=0,this.difficulty=0,this.elapsed_days=0,this.scheduled_days=0,this.reps=0,this.lapses=0,this.state=exports.State.New,this.last_review=new Date},exports.FSRS=o;
"use strict";function t(){return(t=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t}).apply(this,arguments)}var e,i;Object.defineProperty(exports,"__esModule",{value:!0}),(e=exports.State||(exports.State={}))[e.New=0]="New",e[e.Learning=1]="Learning",e[e.Review=2]="Review",e[e.Relearning=3]="Relearning",(i=exports.Rating||(exports.Rating={}))[i.Again=1]="Again",i[i.Hard=2]="Hard",i[i.Good=3]="Good",i[i.Easy=4]="Easy";var a=function(t,e,i,a,s){this.rating=t,this.elapsed_days=i,this.scheduled_days=e,this.review=a,this.state=s},s=function(t,e){this.card=t,this.review_log=e},n=function(){function e(e){this.again=t({},e),this.hard=t({},e),this.good=t({},e),this.easy=t({},e)}var i=e.prototype;return i.update_state=function(t){t===exports.State.New?(this.again.state=exports.State.Learning,this.hard.state=exports.State.Learning,this.good.state=exports.State.Learning,this.easy.state=exports.State.Review):t===exports.State.Learning||t===exports.State.Relearning?(this.again.state=t,this.hard.state=t,this.good.state=exports.State.Review,this.easy.state=exports.State.Review):t===exports.State.Review&&(this.again.state=exports.State.Relearning,this.hard.state=exports.State.Review,this.good.state=exports.State.Review,this.easy.state=exports.State.Review,this.again.lapses+=1)},i.schedule=function(t,e,i,a){this.again.scheduled_days=0,this.hard.scheduled_days=e,this.good.scheduled_days=i,this.easy.scheduled_days=a,this.again.due=new Date(t.getTime()+3e5),this.hard.due=e>0?new Date(t.getTime()+24*e*60*60*1e3):new Date(t.getTime()+6e5),this.good.due=new Date(t.getTime()+24*i*60*60*1e3),this.easy.due=new Date(t.getTime()+24*a*60*60*1e3)},i.record_log=function(t,e){var i;return(i={})[exports.Rating.Again]=new s(this.again,new a(exports.Rating.Again,this.again.scheduled_days,t.elapsed_days,e,t.state)),i[exports.Rating.Hard]=new s(this.hard,new a(exports.Rating.Hard,this.hard.scheduled_days,t.elapsed_days,e,t.state)),i[exports.Rating.Good]=new s(this.good,new a(exports.Rating.Good,this.good.scheduled_days,t.elapsed_days,e,t.state)),i[exports.Rating.Easy]=new s(this.easy,new a(exports.Rating.Easy,this.easy.scheduled_days,t.elapsed_days,e,t.state)),i},e}(),r=function(){this.request_retention=.9,this.maximum_interval=36500,this.w=[.4,.6,2.4,5.8,4.93,.94,.86,.01,1.49,.14,.94,2.18,.05,.34,1.26,.29,2.61]},o=function(){function e(){this.p=new r}var i=e.prototype;return i.repeat=function(e,i){(e=t({},e)).elapsed_days=e.state===exports.State.New?0:(i.getTime()-e.last_review.getTime())/864e5,e.last_review=i,e.reps+=1;var a=new n(e);if(a.update_state(e.state),e.state===exports.State.New){this.init_ds(a),a.again.due=new Date(i.getTime()+6e4),a.hard.due=new Date(i.getTime()+3e5),a.good.due=new Date(i.getTime()+6e5);var s=this.next_interval(a.easy.stability);a.easy.scheduled_days=s,a.easy.due=new Date(i.getTime()+24*s*60*60*1e3)}else if(e.state===exports.State.Learning||e.state===exports.State.Relearning){var r=this.next_interval(a.good.stability),o=Math.max(this.next_interval(a.easy.stability),r+1);a.schedule(i,0,r,o)}else if(e.state===exports.State.Review){var h=e.difficulty,d=e.stability,l=Math.pow(1+e.elapsed_days/(9*d),-1);this.next_ds(a,h,d,l);var p=this.next_interval(a.hard.stability),y=this.next_interval(a.good.stability);p=Math.min(p,y),y=Math.max(y,p+1);var g=Math.max(this.next_interval(a.easy.stability),y+1);a.schedule(i,p,y,g)}return a.record_log(e,i)},i.init_ds=function(t){t.again.difficulty=this.init_difficulty(exports.Rating.Again),t.again.stability=this.init_stability(exports.Rating.Again),t.hard.difficulty=this.init_difficulty(exports.Rating.Hard),t.hard.stability=this.init_stability(exports.Rating.Hard),t.good.difficulty=this.init_difficulty(exports.Rating.Good),t.good.stability=this.init_stability(exports.Rating.Good),t.easy.difficulty=this.init_difficulty(exports.Rating.Easy),t.easy.stability=this.init_stability(exports.Rating.Easy)},i.next_ds=function(t,e,i,a){t.again.difficulty=this.next_difficulty(e,exports.Rating.Again),t.again.stability=this.next_forget_stability(e,i,a),t.hard.difficulty=this.next_difficulty(e,exports.Rating.Hard),t.hard.stability=this.next_recall_stability(e,i,a,exports.Rating.Hard),t.good.difficulty=this.next_difficulty(e,exports.Rating.Good),t.good.stability=this.next_recall_stability(e,i,a,exports.Rating.Good),t.easy.difficulty=this.next_difficulty(e,exports.Rating.Easy),t.easy.stability=this.next_recall_stability(e,i,a,exports.Rating.Easy)},i.init_stability=function(t){return Math.max(this.p.w[t-1],.1)},i.init_difficulty=function(t){return Math.min(Math.max(this.p.w[4]-this.p.w[5]*(t-3),1),10)},i.next_interval=function(t){return Math.min(Math.max(Math.round(9*t*(1/this.p.request_retention-1)),1),this.p.maximum_interval)},i.next_difficulty=function(t,e){return Math.min(Math.max(this.mean_reversion(this.p.w[4],t-this.p.w[6]*(e-3)),1),10)},i.mean_reversion=function(t,e){return this.p.w[7]*t+(1-this.p.w[7])*e},i.next_recall_stability=function(t,e,i,a){var s=a===exports.Rating.Hard?this.p.w[15]:1,n=a===exports.Rating.Easy?this.p.w[16]:1;return e*(1+Math.exp(this.p.w[8])*(11-t)*Math.pow(e,-this.p.w[9])*(Math.exp((1-i)*this.p.w[10])-1)*s*n)},i.next_forget_stability=function(t,e,i){return this.p.w[11]*Math.pow(t,-this.p.w[12])*(Math.pow(e+1,this.p.w[13])-1)*Math.exp((1-i)*this.p.w[14])},e}();exports.Card=function(){this.due=new Date,this.stability=0,this.difficulty=0,this.elapsed_days=0,this.scheduled_days=0,this.reps=0,this.lapses=0,this.state=exports.State.New,this.last_review=new Date},exports.FSRS=o,exports.ReviewLog=a,exports.SchedulingInfo=s;
//# sourceMappingURL=fsrs.js.cjs.production.min.js.map

@@ -196,3 +196,3 @@ function _extends() {

export { Card, FSRS, Rating, State };
export { Card, FSRS, Rating, ReviewLog, SchedulingInfo, State };
//# sourceMappingURL=fsrs.js.esm.js.map

@@ -13,3 +13,3 @@ export declare enum State {

}
declare class ReviewLog {
export declare class ReviewLog {
rating: Rating;

@@ -34,3 +34,3 @@ scheduled_days: number;

}
declare class SchedulingInfo {
export declare class SchedulingInfo {
card: Card;

@@ -37,0 +37,0 @@ review_log: ReviewLog;

{
"version": "1.2.0",
"version": "1.2.1",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -15,3 +15,3 @@ export enum State {

class ReviewLog {
export class ReviewLog {
rating: Rating;

@@ -60,3 +60,3 @@ scheduled_days: number;

class SchedulingInfo {
export class SchedulingInfo {
card: Card;

@@ -63,0 +63,0 @@ review_log: ReviewLog;

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc