diff --git a/README.md b/README.md index 5f7cfc9..c125327 100644 --- a/README.md +++ b/README.md @@ -9,15 +9,6 @@ developers apply FSRS to their flashcard applications, there by improving the us npm install ts-fsrs ``` -# Environment Variables -If you need to customize default parameters, you can modify the values using `.env`/`.env.local`/`.env.production`/`.env.development`. - -Copy the [.env.local.example](./example/.env.local.example) file in this directory to .env.local (which will be ignored by Git): - -```bash -cp .env.local.example .env.local -``` - # Example ```typescript diff --git a/__tests__/models.test.ts b/__tests__/models.test.ts index 688ac3b..539b8f7 100644 --- a/__tests__/models.test.ts +++ b/__tests__/models.test.ts @@ -1,5 +1,4 @@ import { - envParams, Rating, RatingType, State, @@ -77,30 +76,23 @@ describe("Rating", () => { }); describe("default FSRSParameters", () => { - const env = envParams; + // const env = envParams; const params = generatorParameters(); const w_v4 = [ 0.4, 0.6, 2.4, 5.8, 4.93, 0.94, 0.86, 0.01, 1.49, 0.14, 0.94, 2.18, 0.05, 0.34, 1.26, 0.29, 2.61, ]; it("default_request_retention", () => { - expect([0.9, env.FSRS_REQUEST_RETENTION]).toContainEqual( - params.request_retention, - ); + expect(0.9).toEqual(params.request_retention); }); it("default_maximum_interval", () => { - expect([36500, env.FSRS_MAXIMUM_INTERVAL]).toContainEqual( - params.maximum_interval, - ); + expect(36500).toEqual(params.maximum_interval); }); it("default_w ", () => { - expect([w_v4, env.FSRS_W]).toContainEqual(params.w); - if (env.FSRS_W) { - expect(env.FSRS_W.length).toEqual(w_v4.length); - } + expect(w_v4).toEqual(params.w); }); it("default_enable_fuzz ", () => { - expect([false, env.FSRS_ENABLE_FUZZ]).toContainEqual(params.enable_fuzz); + expect(false).toEqual(params.enable_fuzz); }); }); diff --git a/example/.env.local.example b/example/.env.local.example deleted file mode 100644 index 0f17ba4..0000000 --- a/example/.env.local.example +++ /dev/null @@ -1,4 +0,0 @@ -FSRS_REQUEST_RETENTION=0.8 -FSRS_MAXIMUM_INTERVAL=36500 -FSRS_W='[0.4, 0.6, 2.4, 5.8, 4.93, 0.94, 0.86, 0.01, 1.49, 0.14, 0.94, 2.18, 0.05, 0.34, 1.26, 0.29, 2.61]' -FSRS_ENABLE_FUZZ=true \ No newline at end of file diff --git a/package.json b/package.json index d5d14c4..1146822 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-fsrs", - "version": "3.1.0-beta6", + "version": "3.1.0-beta7", "description": "ts-fsrs is a TypeScript package used to implement the Free Spaced Repetition Scheduler (FSRS) algorithm. It helps developers apply FSRS to their flashcard applications, thereby improving the user learning experience.", "main": "dist/ts-fsrs.js", "module": "dist/ts-fsrs.mjs", @@ -13,7 +13,6 @@ "FSRS" ], "dependencies": { - "dotenv": "^16.3.1", "seedrandom": "^3.0.5" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 950063d..98c5208 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,9 +5,6 @@ settings: excludeLinksFromLockfile: false dependencies: - dotenv: - specifier: ^16.3.1 - version: 16.3.1 seedrandom: specifier: ^3.0.5 version: 3.0.5 @@ -2546,11 +2543,6 @@ packages: esutils: 2.0.3 dev: true - /dotenv@16.3.1: - resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==} - engines: {node: '>=12'} - dev: false - /eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} dev: true diff --git a/src/fsrs/default.ts b/src/fsrs/default.ts index 6718c5b..d6ced4d 100644 --- a/src/fsrs/default.ts +++ b/src/fsrs/default.ts @@ -1,40 +1,15 @@ import { Card, DateInput, FSRSParameters, State } from "./models"; import { fixDate } from "./help"; -import { EnvParams } from "./type"; -import dotenv from "dotenv"; -if (typeof window === "undefined") { - dotenv.config({ path: `./.env.local` }); - dotenv.config({ path: `./.env.production` }); - dotenv.config({ path: `./.env.` }); - dotenv.config({ path: `./.env.development` }); -} - -export const envParams: EnvParams = { - FSRS_REQUEST_RETENTION: Number(process && process.env.FSRS_REQUEST_RETENTION), - FSRS_MAXIMUM_INTERVAL: Number(process && process.env.FSRS_MAXIMUM_INTERVAL), - FSRS_W: - process && process.env.FSRS_W - ? JSON.parse(process.env.FSRS_W as string) - : undefined, - FSRS_ENABLE_FUZZ: Boolean(process && process.env.FSRS_ENABLE_FUZZ), -}; - -export const default_request_retention = !isNaN( - envParams.FSRS_REQUEST_RETENTION, -) - ? envParams.FSRS_REQUEST_RETENTION - : 0.9; -export const default_maximum_interval = !isNaN(envParams.FSRS_MAXIMUM_INTERVAL) - ? envParams.FSRS_MAXIMUM_INTERVAL - : 36500; -export const default_w = envParams.FSRS_W || [ +export const default_request_retention = 0.9; +export const default_maximum_interval = 36500; +export const default_w = [ 0.4, 0.6, 2.4, 5.8, 4.93, 0.94, 0.86, 0.01, 1.49, 0.14, 0.94, 2.18, 0.05, 0.34, 1.26, 0.29, 2.61, ]; -export const default_enable_fuzz = envParams.FSRS_ENABLE_FUZZ || false; +export const default_enable_fuzz = false; -export const FSRSVersion: string = "3.1.0-beta6"; +export const FSRSVersion: string = "3.1.0-beta7"; export const generatorParameters = ( props?: Partial, diff --git a/src/fsrs/index.ts b/src/fsrs/index.ts index d578a5d..abb5411 100644 --- a/src/fsrs/index.ts +++ b/src/fsrs/index.ts @@ -6,8 +6,7 @@ export { default_enable_fuzz, FSRSVersion, generatorParameters, - createEmptyCard, - envParams + createEmptyCard } from "./default"; export { date_scheduler, diff --git a/src/fsrs/type.ts b/src/fsrs/type.ts index 1d53154..4aced0a 100644 --- a/src/fsrs/type.ts +++ b/src/fsrs/type.ts @@ -1,10 +1,3 @@ export type unit = "days" | "minutes"; export type int = number & { __int__: void }; export type double = number & { __double__: void }; - -export interface EnvParams{ - FSRS_REQUEST_RETENTION:number, - FSRS_MAXIMUM_INTERVAL:number, - FSRS_W?:number[], - FSRS_ENABLE_FUZZ?:boolean -} \ No newline at end of file