@pdfvector/util 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ export declare function getNextMonthDate(timestamp: number): Date;
2
+ export declare function getPreviousMonthDate(): Date;
3
+ export declare function formatShortDateTime(date: Date | number): string;
4
+ export declare function formatLongDateTime(date: Date | number): string;
@@ -0,0 +1,32 @@
1
+ export function getNextMonthDate(timestamp) {
2
+ const date = new Date(timestamp);
3
+ date.setMonth(date.getMonth() + 1);
4
+ return date;
5
+ }
6
+ export function getPreviousMonthDate() {
7
+ const date = new Date();
8
+ date.setMonth(date.getMonth() - 1);
9
+ return date;
10
+ }
11
+ export function formatShortDateTime(date) {
12
+ const d = typeof date === "number" ? new Date(date) : date;
13
+ return new Intl.DateTimeFormat("en-US", {
14
+ month: "short",
15
+ day: "numeric",
16
+ hour: "numeric",
17
+ minute: "2-digit",
18
+ }).format(d);
19
+ }
20
+ export function formatLongDateTime(date) {
21
+ const d = typeof date === "number" ? new Date(date) : date;
22
+ const datePart = new Intl.DateTimeFormat("en-US", {
23
+ month: "short",
24
+ day: "numeric",
25
+ year: "numeric",
26
+ }).format(d);
27
+ const timePart = new Intl.DateTimeFormat("en-US", {
28
+ hour: "numeric",
29
+ minute: "2-digit",
30
+ }).format(d);
31
+ return `on ${datePart} at ${timePart}`;
32
+ }
@@ -0,0 +1 @@
1
+ export declare function formatNumber(value: number): string;
@@ -0,0 +1,3 @@
1
+ export function formatNumber(value) {
2
+ return value.toLocaleString("en-US");
3
+ }
@@ -0,0 +1 @@
1
+ export declare function getErrorMessage(error: unknown): string;
@@ -0,0 +1,7 @@
1
+ export function getErrorMessage(error) {
2
+ if (error instanceof Error)
3
+ return error.message;
4
+ if (typeof error === "string")
5
+ return error;
6
+ return "An unknown error occurred";
7
+ }
@@ -1,3 +1,7 @@
1
+ export * from "./date";
2
+ export * from "./format";
3
+ export * from "./get-error-message";
4
+ export * from "./plan";
1
5
  export declare const isCI: boolean;
2
6
  export declare const isLocal: boolean;
3
7
  export declare const isLive: boolean;
package/.tsc/lib/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ export * from "./date";
2
+ export * from "./format";
3
+ export * from "./get-error-message";
4
+ export * from "./plan";
1
5
  function getCIWithBun() {
2
6
  try {
3
7
  return Bun.env.CI;
@@ -0,0 +1,24 @@
1
+ export interface PlanDefinition {
2
+ label: string;
3
+ monthlyCredits: number;
4
+ monthlyPrice: number;
5
+ annualPrice: number;
6
+ }
7
+ export type PlanKey = "free" | "basic" | "pro";
8
+ export interface Plan {
9
+ key: PlanKey;
10
+ annual: boolean;
11
+ }
12
+ export interface PlanSchedule {
13
+ plan: Plan;
14
+ date: Date;
15
+ }
16
+ export interface ChangedPlan {
17
+ key: PlanKey;
18
+ time: number;
19
+ credits: number;
20
+ }
21
+ export declare const planDefinitions: Record<PlanKey, PlanDefinition>;
22
+ export declare const planKeys: [PlanKey, ...PlanKey[]];
23
+ export declare function isPlanKey(value: string): value is PlanKey;
24
+ export declare function formatPlanLabel(plan: Plan): string;
@@ -0,0 +1,31 @@
1
+ export const planDefinitions = {
2
+ free: {
3
+ label: "Free",
4
+ monthlyCredits: 100,
5
+ monthlyPrice: 0,
6
+ annualPrice: 0,
7
+ },
8
+ basic: {
9
+ label: "Basic",
10
+ monthlyCredits: 3000,
11
+ monthlyPrice: 25,
12
+ annualPrice: 23,
13
+ },
14
+ pro: {
15
+ label: "Pro",
16
+ monthlyCredits: 100000,
17
+ monthlyPrice: 97,
18
+ annualPrice: 89,
19
+ },
20
+ };
21
+ export const planKeys = Object.keys(planDefinitions);
22
+ export function isPlanKey(value) {
23
+ return planKeys.includes(value);
24
+ }
25
+ export function formatPlanLabel(plan) {
26
+ const parts = ["the", planDefinitions[plan.key].label];
27
+ if (plan.key !== "free")
28
+ parts.push(plan.annual ? "annual" : "monthly");
29
+ parts.push("plan");
30
+ return parts.join(" ");
31
+ }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @pdfvector/util
2
2
 
3
+ ## 0.0.12
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#82](https://github.com/phuctm97/pdfvector/pull/82) [`56c9406`](https://github.com/phuctm97/pdfvector/commit/56c94061e0622599a5f4edce21416c6b2adbc56b) Thanks [@khanhduyvt0101](https://github.com/khanhduyvt0101)! - Update spa
9
+
3
10
  ## 0.0.11
4
11
  ### Patch Changes
5
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfvector/util",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "main": ".tsc/lib/index.js",
6
6
  "files": [