utilium 0.1.0 → 0.1.2

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.
package/dist/objects.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
- export declare function filterObject<T extends object, K extends keyof T>(object: T, ...keys: K[]): Omit<T, K>;
3
2
  import type * as FS from 'fs';
3
+ export declare function filterObject<T extends object, K extends keyof T>(object: T, ...keys: K[]): Omit<T, K>;
4
4
  export declare function isJSON(str: string): boolean;
5
5
  export declare abstract class FileMap<V> implements Map<string, V> {
6
6
  protected readonly path: string;
7
7
  protected fs: typeof FS;
8
8
  get [Symbol.toStringTag](): string;
9
- constructor(path: string, fs?: typeof FS);
9
+ constructor(path: string, fs: typeof FS);
10
10
  protected abstract readonly _map: Map<string, V>;
11
11
  abstract clear(): void;
12
12
  abstract delete(key: string): boolean;
package/dist/objects.js CHANGED
@@ -2,13 +2,6 @@ export function filterObject(object, ...keys) {
2
2
  const entries = Object.entries(object);
3
3
  return Object.fromEntries(entries.filter(([key]) => keys.includes(key)));
4
4
  }
5
- let _fs;
6
- try {
7
- _fs = await import('fs');
8
- }
9
- catch (e) {
10
- _fs = null;
11
- }
12
5
  export function isJSON(str) {
13
6
  try {
14
7
  JSON.parse(str);
@@ -22,7 +15,7 @@ export class FileMap {
22
15
  get [Symbol.toStringTag]() {
23
16
  return 'FileMap';
24
17
  }
25
- constructor(path, fs = _fs) {
18
+ constructor(path, fs) {
26
19
  this.path = path;
27
20
  this.fs = fs;
28
21
  if (!path) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utilium",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Typescript utilies",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/objects.ts CHANGED
@@ -1,17 +1,10 @@
1
+ import type * as FS from 'fs';
2
+
1
3
  export function filterObject<T extends object, K extends keyof T>(object: T, ...keys: K[]): Omit<T, K> {
2
4
  const entries = <[K, T[K]][]>Object.entries(object);
3
5
  return <Omit<T, K>>(<unknown>Object.fromEntries(entries.filter(([key]) => keys.includes(key))));
4
6
  }
5
7
 
6
- import type * as FS from 'fs';
7
-
8
- let _fs: typeof FS;
9
- try {
10
- _fs = await import('fs');
11
- } catch (e) {
12
- _fs = null;
13
- }
14
-
15
8
  export function isJSON(str: string) {
16
9
  try {
17
10
  JSON.parse(str);
@@ -28,7 +21,7 @@ export abstract class FileMap<V> implements Map<string, V> {
28
21
 
29
22
  public constructor(
30
23
  protected readonly path: string,
31
- protected fs: typeof FS = _fs
24
+ protected fs: typeof FS
32
25
  ) {
33
26
  if (!path) {
34
27
  throw new ReferenceError('No path specified');