Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary dependencies #36

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/violet-comics-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'chronoshift': patch
---

Removed unnecessary dependencies
28 changes: 5 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
},
"prettier": "@awesome-code-style/prettier-config",
"dependencies": {
"immutable-class": "^0.11.0",
"@internationalized/date": "^3.5.6",
"tslib": "^2.8.1"
},
Expand All @@ -67,12 +66,12 @@
"@changesets/cli": "^2.27.10",
"@types/jest": "^29.5.14",
"@types/jest-expect-message": "^1.0.3",
"@types/moment-timezone": "^0.5.12",
"@types/node": "^20.0.0",
"eslint": "^9.15.0",
"eslint-plugin-notice": "^1.0.0",
"globals": "^15.12.0",
"husky": "^2.4.1",
"immutable-class": "^0.11.0",
"immutable-class-tester": "^0.7.2",
"jest": "^29.7.0",
"jest-expect-message": "^1.1.3",
Expand Down
5 changes: 2 additions & 3 deletions src/duration/duration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
* limitations under the License.
*/

import type { Instance } from 'immutable-class';

import { second, shifters } from '../floor-shift-ceil/floor-shift-ceil';
import type { Timezone } from '../timezone/timezone';
import type { ImmutableClassInstance } from '../utils/utils';

const SPANS_WITH_WEEK = ['year', 'month', 'week', 'day', 'hour', 'minute', 'second'];
const SPANS_WITHOUT_WEEK = ['year', 'month', 'day', 'hour', 'minute', 'second'];
Expand Down Expand Up @@ -142,7 +141,7 @@ function fitIntoSpans(length: number, spansToCheck: string[]): Record<string, nu
/**
* Represents an ISO duration like P1DT3H
*/
export class Duration implements Instance<DurationValue, string> {
export class Duration implements ImmutableClassInstance<DurationValue, string> {
public singleSpan?: string;
public spans: DurationValue;

Expand Down
4 changes: 0 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@
* limitations under the License.
*/

import momentTz from 'moment-timezone';

export * from './date-parser/date-parser';
export * from './duration/duration';
export * from './floor-shift-ceil/floor-shift-ceil';
export * from './timezone/timezone';
export * from './utils/utils';

export const moment: any = momentTz;
5 changes: 3 additions & 2 deletions src/timezone/timezone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
*/

import { fromDate } from '@internationalized/date';
import type { Instance } from 'immutable-class';

import type { ImmutableClassInstance } from '../utils/utils';

/**
* Represents timezones
*/
export class Timezone implements Instance<string, string> {
export class Timezone implements ImmutableClassInstance<string, string> {
static UTC: Timezone = new Timezone('Etc/UTC');

private readonly timezone: string;
Expand Down
11 changes: 11 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
* limitations under the License.
*/

/**
* Duck-type comptible interface for `Instance` from `immutable-class` to avoid
* adding it as a regular dependency.
*/
export interface ImmutableClassInstance<ValueType, JSType> {
valueOf(): ValueType;
toJS(): JSType;
toJSON(): JSType;
equals(other: ImmutableClassInstance<ValueType, JSType> | undefined): boolean;
}

export function isDate(d: any) {
return !!(d && d.toISOString);
}
Loading