@holz/pattern-filter 0.1.0 → 0.2.0

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 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=t=>t.split(/[\s,]+/).filter(Boolean).reduce((s,r)=>(r[0]==="-"?s.exclude.push(c(r.slice(1))):s.include.push(c(r)),s),{include:[],exclude:[]}),n=(t,e)=>t.exclude.every(s=>!s.test(e))&&t.include.some(s=>s.test(e)),c=t=>{const e=t.replace(/\*/g,".*?");return new RegExp(`^${e}$`)};class o{constructor(e){this.pattern=e.pattern,this.processor=e.processor,this.filters=l(e.pattern)}processLog(e){n(this.filters,e.origin.join(":"))&&this.processor.processLog(e)}}exports.PatternFilter=o;exports.default=o;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@holz/pattern-filter",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Only print log messages that match a pattern",
5
5
  "type": "module",
6
- "main": "./dist/holz-pattern-filter.umd.cjs",
6
+ "main": "./dist/holz-pattern-filter.cjs",
7
7
  "module": "./dist/holz-pattern-filter.js",
8
8
  "types": "./src/index.ts",
9
9
  "repository": {
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "exports": {
15
15
  ".": {
16
- "require": "./dist/holz-pattern-filter.umd.cjs",
16
+ "require": "./dist/holz-pattern-filter.cjs",
17
17
  "import": "./dist/holz-pattern-filter.js"
18
18
  }
19
19
  },
@@ -35,12 +35,12 @@
35
35
  "exclude"
36
36
  ],
37
37
  "scripts": {
38
- "prepare": "vite build",
38
+ "prepack": "vite build",
39
39
  "test:unit": "vitest --color --passWithNoTests",
40
40
  "test:types": "tsc"
41
41
  },
42
42
  "devDependencies": {
43
- "@holz/core": "0.1.0",
43
+ "@holz/core": "0.2.0",
44
44
  "@vitest/coverage-c8": "0.28.5",
45
45
  "typescript": "4.9.5",
46
46
  "vite": "^4.0.0",
@@ -1 +0,0 @@
1
- (function(t,n){typeof exports=="object"&&typeof module<"u"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(t=typeof globalThis<"u"?globalThis:t||self,n(t["holz-pattern-filter"]={}))})(this,function(t){"use strict";const n=s=>s.split(/[\s,]+/).filter(Boolean).reduce((r,i)=>(i[0]==="-"?r.exclude.push(o(i.slice(1))):r.include.push(o(i)),r),{include:[],exclude:[]}),l=(s,e)=>s.exclude.every(r=>!r.test(e))&&s.include.some(r=>r.test(e)),o=s=>{const e=s.replace(/\*/g,".*?");return new RegExp(`^${e}$`)};class c{constructor(e){this.pattern=e.pattern,this.processor=e.processor,this.filters=n(e.pattern)}processLog(e){l(this.filters,e.origin.join(":"))&&this.processor.processLog(e)}}t.PatternFilter=c,t.default=c,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});