{"_id":"zeptomatch-explode","_rev":"3757988","name":"zeptomatch-explode","description":"A little utility for exploding a zeptomatch-flavored glob into its dynamic and static parts.","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"time":{"modified":"2025-03-18T07:12:47.000Z","created":"2024-03-27T18:34:42.436Z","1.0.1":"2025-03-05T23:39:21.688Z","1.0.0":"2024-03-27T18:34:42.436Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/fabiospampinato/zeptomatch-explode.git"},"versions":{"1.0.1":{"name":"zeptomatch-explode","repository":{"type":"git","url":"git+https://github.com/fabiospampinato/zeptomatch-explode.git"},"description":"A little utility for exploding a zeptomatch-flavored glob into its dynamic and static parts.","license":"MIT","version":"1.0.1","type":"module","sideEffects":false,"main":"dist/index.js","exports":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"clean":"tsex clean","compile":"tsex compile","compile:watch":"tsex compile --watch","test":"tsex test","test:watch":"tsex test --watch","prepublishOnly":"tsex prepare"},"keywords":["zeptomatch","explode","glob","start","end"],"devDependencies":{"fava":"^0.3.4","tsex":"^4.0.2","typescript":"^5.8.2"},"_id":"zeptomatch-explode@1.0.1","gitHead":"7a5113328cb4be810246cc997823bedb8d27cadf","bugs":{"url":"https://github.com/fabiospampinato/zeptomatch-explode/issues"},"homepage":"https://github.com/fabiospampinato/zeptomatch-explode#readme","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"shasum":"a36729dedcb215d62265d6a342b5b84c809c9044","size":3206,"noattachment":false,"key":"/zeptomatch-explode/-/zeptomatch-explode-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/zeptomatch-explode/download/zeptomatch-explode-1.0.1.tgz"},"_npmUser":{"name":"fabiospampinato","email":"spampinabio@gmail.com"},"directories":{},"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/zeptomatch-explode_1.0.1_1741217961485_0.1051270312819792"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-03-05T23:39:21.688Z","publish_time":1741217961688,"_source_registry_name":"default","_cnpm_publish_time":1741217961688},"1.0.0":{"name":"zeptomatch-explode","repository":{"type":"git","url":"git+https://github.com/fabiospampinato/zeptomatch-explode.git"},"description":"A little utility for exploding a zeptomatch-flavored glob into its dynamic and static parts.","version":"1.0.0","type":"module","sideEffects":false,"main":"dist/index.js","exports":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"clean":"tsex clean","compile":"tsex compile","compile:watch":"tsex compile --watch","test":"tsex test","test:watch":"tsex test --watch","prepublishOnly":"tsex prepare"},"keywords":["zeptomatch","explode","glob","start","end"],"devDependencies":{"fava":"^0.3.2","tsex":"^3.2.1","typescript":"^5.4.3"},"_id":"zeptomatch-explode@1.0.0","gitHead":"6070b2819eb0807953e590af74b693b5545becaa","bugs":{"url":"https://github.com/fabiospampinato/zeptomatch-explode/issues"},"homepage":"https://github.com/fabiospampinato/zeptomatch-explode#readme","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"shasum":"df5b0cdbf06ff58992be9e85d1fff40739ce0423","size":4683,"noattachment":false,"key":"/zeptomatch-explode/-/zeptomatch-explode-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/zeptomatch-explode/download/zeptomatch-explode-1.0.0.tgz"},"_npmUser":{"name":"fabiospampinato","email":"spampinabio@gmail.com"},"directories":{},"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zeptomatch-explode_1.0.0_1711564482252_0.39501697131644775"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-03-27T18:34:42.436Z","publish_time":1711564482436,"_source_registry_name":"default","_cnpm_publish_time":1711564482436}},"readme":"# Zeptomatch Explode\n\nA little utility for exploding a [`zeptomatch`](https://github.com/fabiospampinato/zeptomatch)-flavored glob into its dynamic and static parts.\n\nThe idea is to extract the static parts of a glob, potentially from both ends, for optimization purposes. Which static parts can be detected as such, and which dynamic parts can be resolved into static parts, is an implementation detail.\n\n## Install\n\n```sh\nnpm install zeptomatch-explode\n```\n\n## Usage\n\n#### `explodeStart`\n\nThis function extracts the static parts of a glob from its start, stopping at the first dynamic part found.\n\nIt returns an array of static parts, and the rest of the glob, the dynamic part. The dynamic part is never empty, unless the entire glob is an empty string, so the last part of a glob is never considered static by this function.\n\nThe static parts are returned as an array because some simple dynamic starts are resolved into all the static strings that would match them.\n\nThe idea is that for example for simple globs that may look like this: `foo/**/*`, instead of searching from the root and then matching against the whole glob, if you extract the static part out of it you can just search for everything inside the `foo` folder, which is potentially faster, as other folders are not searched into and no files need to actually be matched against the glob, in this particular example.\n\n```ts\nimport {explodeStart} from 'zeptomatch-explode';\n\nconst result1 = explodeStart ( 'foo/**/*' );\n\nresult1.statics; // => ['foo']\nresult1.dynamic; // => '**/*'\n\nconst result2 = explodeStart ( 'foo{bar,baz}/**/*' );\n\nresult2.statics; // => ['foobar', 'foobaz']\nresult2.dynamic; // => '**/*'\n\nconst result3 = explodeStart ( 'foo' );\n\nresult3.statics; // => []\nresult3.dynamic; // => 'foo'\n```\n\n#### `explodeEnd`\n\nThis function extracts the static part of a glob from its end, stopping at the first slash found.\n\nIt returns an array of static parts, and the rest of the glob, the dynamic part. The rest of the glob is never empty, it gets generalized automatically to match against any file.\n\nThe static parts are returned as an array because some simple dynamic ends are resolved into all the static strings that would match them.\n\nThe idea is that by extracting this information from the end of a glob you can generate optimized matching functions that just check the end of a path, instead of matching the whole path against the glob, very quickly.\n\n```ts\nimport {explodeEnd} from 'zeptomatch-explode';\n\nconst result1 = explodeEnd ( '**/*.js' );\n\nresult1.flexibleStart; // => true\nresult1.flexibleEnd; // => false\nresult1.statics; // => ['.js']\nresult1.dynamic; // => '**/*'\n\nconst result2 = explodeEnd ( '**/index.{js,ts}' );\n\nresult2.flexibleStart; // => false\nresult2.flexibleEnd; // => false\nresult2.statics; // => ['index.js', 'index.ts']\nresult2.dynamic; // => '**/*'\n\nconst result3 = explodeEnd ( '**/*.test.*' );\n\nresult3.flexibleStart; // => true\nresult3.flexibleEnd; // => true\nresult3.statics; // => ['.test.']\nresult3.dynamic; // => '**/*'\n```\n\n## License\n\nMIT © Fabio Spampinato\n","_attachments":{},"homepage":"https://github.com/fabiospampinato/zeptomatch-explode#readme","bugs":{"url":"https://github.com/fabiospampinato/zeptomatch-explode/issues"},"license":"MIT"}