Skip to content

Commit

Permalink
feat(rrule): generate const enums (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsndr authored May 19, 2024
1 parent 3fa893a commit cda2986
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
},
"scripts": {
"artifacts": "napi artifacts",
"build:lib": "napi build --js src/lib/index.js --dts src/lib/index.d.ts --platform --release",
"postbuild:lib": "cpy ./*.node ./src/lib && rimraf --glob ./*.node",
"build:lib": "napi build --no-const-enum --platform --release src/lib",
"prebuild": "rimraf ./dist && npm run build:lib",
"build": "tsc -p ./tsconfig.build.json",
"postbuild": "cpy ./src/lib/* ./dist/lib --flat",
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './rrule-set';
export * from './rrule';
export * from './datetime';
export { Frequency, Weekday, Month, NWeekday } from './lib';
6 changes: 3 additions & 3 deletions src/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/* auto-generated by NAPI-RS */

export const enum Frequency {
export enum Frequency {
Yearly = 0,
Monthly = 1,
Weekly = 2,
Expand All @@ -12,7 +12,7 @@ export const enum Frequency {
Minutely = 5,
Secondly = 6
}
export const enum Month {
export enum Month {
January = 0,
February = 1,
March = 2,
Expand All @@ -36,7 +36,7 @@ export interface NWeekday {
n?: number
weekday: Weekday
}
export const enum Weekday {
export enum Weekday {
Monday = 0,
Tuesday = 1,
Wednesday = 2,
Expand Down
1 change: 1 addition & 0 deletions src/rrule-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface RRuleSetLike {
}

export class RRuleSet implements Iterable<DateTime> {
/** @internal */
private rust?: Rust;

public readonly dtstart: DateTime;
Expand Down
48 changes: 47 additions & 1 deletion src/rrule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,51 @@
import { DateTime } from './datetime';
import { RRule as Rust, Frequency, NWeekday, Month, Weekday } from './lib';
import { RRule as Rust } from './lib';

export interface NWeekday {
/**
* If set, this represents the nth occurrence of the weekday.
* Otherwise it represents every occurrence of the weekday.
*
* A negative value represents nth occurrence from the end.
*/
n?: number;
weekday: Weekday;
}

export enum Frequency {
Yearly = 0,
Monthly = 1,
Weekly = 2,
Daily = 3,
Hourly = 4,
Minutely = 5,
Secondly = 6,
}

export enum Month {
January = 0,
February = 1,
March = 2,
April = 3,
May = 4,
June = 5,
July = 6,
August = 7,
September = 8,
October = 9,
November = 10,
December = 11,
}

export enum Weekday {
Monday = 0,
Tuesday = 1,
Wednesday = 2,
Thursday = 3,
Friday = 4,
Saturday = 5,
Sunday = 6,
}

export interface RRuleLike {
readonly frequency: Frequency;
Expand Down

0 comments on commit cda2986

Please sign in to comment.