@holz/env-filter 0.6.1 → 0.7.0-rc.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.
@@ -0,0 +1,18 @@
1
+ import { LogProcessor } from '@holz/core';
2
+
3
+ declare interface Config {
4
+ /** Replace the detected pattern with something else. */
5
+ pattern?: string;
6
+ /** The default pattern to use if no pattern is provided. */
7
+ defaultPattern?: string;
8
+ /** Where to send the logs if they pass the filter. */
9
+ processor: LogProcessor;
10
+ /** The localStorage key where patterns are saved. Default is `debug`. */
11
+ localStorageKey?: string;
12
+ /** The environment variable where patterns are saved. Default is `DEBUG`. */
13
+ environmentVariable?: string;
14
+ }
15
+
16
+ export declare const createEnvironmentFilter: ({ processor, pattern, defaultPattern, localStorageKey, environmentVariable, }: Config) => LogProcessor;
17
+
18
+ export { }
@@ -16,7 +16,7 @@ const c = (e) => {
16
16
  environmentVariable: o = "DEBUG"
17
17
  }) => a({
18
18
  processor: e,
19
- pattern: t ?? (() => i(n) ?? c(o))() ?? r ?? "*"
19
+ pattern: t ?? (i(n) ?? c(o)) ?? r ?? "*"
20
20
  });
21
21
  export {
22
22
  m as createEnvironmentFilter
package/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "@holz/env-filter",
3
- "version": "0.6.1",
3
+ "version": "0.7.0-rc.2",
4
4
  "description": "Filter logs based on the current environment.",
5
5
  "type": "module",
6
- "main": "./dist/holz-env-filter.cjs",
7
- "module": "./dist/holz-env-filter.js",
8
- "types": "./src/index.ts",
9
6
  "repository": {
10
7
  "type": "git",
11
8
  "url": "https://github.com/PsychoLlama/holz",
@@ -13,6 +10,7 @@
13
10
  },
14
11
  "exports": {
15
12
  ".": {
13
+ "types": "./dist/holz-env-filter.d.ts",
16
14
  "require": "./dist/holz-env-filter.cjs",
17
15
  "import": "./dist/holz-env-filter.js"
18
16
  }
@@ -40,16 +38,19 @@
40
38
  "test:types": "tsc"
41
39
  },
42
40
  "dependencies": {
43
- "@holz/pattern-filter": "^0.6.1"
41
+ "@holz/pattern-filter": "^0.7.0-rc.2"
44
42
  },
45
43
  "peerDependencies": {
46
- "@holz/core": "0.6.0"
44
+ "@holz/core": "0.7.0-rc.2"
47
45
  },
48
46
  "devDependencies": {
49
- "@holz/core": "^0.6.0",
50
- "@types/node": "^18.14.0",
51
- "@vitest/coverage-v8": "^0.33.0",
52
- "vite": "^4.0.0",
53
- "vitest": "^0.33.0"
54
- }
47
+ "@holz/core": "^0.7.0-rc.2",
48
+ "@types/node": "^22.0.0",
49
+ "@vitest/coverage-v8": "^3.0.8",
50
+ "vite": "^6.0.0",
51
+ "vite-plugin-dts": "^4.5.3",
52
+ "vite-tsconfig-paths": "^5.1.4",
53
+ "vitest": "^3.0.8"
54
+ },
55
+ "stableVersion": "0.6.1"
55
56
  }
@@ -1,7 +1,7 @@
1
1
  import * as env from '../get-env';
2
2
 
3
3
  class MockLocalStorage {
4
- private store = new Map();
4
+ private store = new Map<string, string>();
5
5
 
6
6
  getItem = vi.fn((key: string) => this.store.get(key) ?? null);
7
7
  setItem = vi.fn((key: string, value: string) => {
package/src/get-env.ts CHANGED
@@ -9,7 +9,7 @@ export const getLocalStorageKey = (key: string): undefined | string => {
9
9
  if (typeof localStorage !== 'undefined') {
10
10
  return localStorage.getItem(key) ?? undefined;
11
11
  }
12
- } catch (error) {
12
+ } catch {
13
13
  // Sometimes localStorage fails (e.g. in Safari private mode). That's
14
14
  // okay. We'll just use a fallback pattern.
15
15
  }