{"_id":"@ahmillat/js-hooks","_rev":"1-5cfc4bfb86706f50e28e854160dca828","name":"@ahmillat/js-hooks","description":"A versatile JavaScript hooks system inspired by WordPress.","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@ahmillat/js-hooks","version":"1.0.0","keywords":["hooks","javascript","actions","filters"],"author":{"name":"Ahsanul Haque Millat"},"license":"MIT","_id":"@ahmillat/js-hooks@1.0.0","homepage":"https://github.com/SneherAdor/js-hooks#readme","bugs":{"url":"https://github.com/SneherAdor/js-hooks/issues"},"dist":{"shasum":"08c5b37aae5928f1446d38550c74c331f7272346","tarball":"https://registry.npmjs.org/@ahmillat/js-hooks/-/js-hooks-1.0.0.tgz","fileCount":9,"integrity":"sha512-l7GbGUVPSUts+v/fVRUTd60w1KWEUMTgNobPDVeQPBQOdba2tEM0AGTTh6Jvo3FNXnjbxwwS5gXFqCnqS+lFiQ==","signatures":[{"sig":"MEQCID+qSIcVqI6xC+HmsDCz77VtTRW+Q3f0rlufzLVe7bSQAiAVFTRH8CbTjae36wDBdR3iTdWeaUwEoqvv4x+EmAoyjQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32393},"main":"dist/hooks.js","gitHead":"ab7f8e89af052a92e9d073eadb832f63079a501e","scripts":{"test":"mocha test/hooks.test.js","build":"webpack --mode production"},"_npmUser":{"name":"ahmillat","email":"sneherador.sa.sa@gmail.com"},"repository":{"url":"git+https://github.com/SneherAdor/js-hooks.git","type":"git"},"_npmVersion":"10.8.1","description":"A versatile JavaScript hooks system inspired by WordPress.","directories":{"test":"test","example":"examples"},"_nodeVersion":"22.3.0","dependencies":{"he":"^1.2.0","ms":"^2.1.2","ajv":"^6.12.6","diff":"^5.0.0","flat":"^5.0.2","glob":"^7.1.6","keyv":"^4.5.4","levn":"^0.4.1","once":"^1.4.0","y18n":"^5.0.8","acorn":"^7.4.1","chalk":"^4.1.2","cliui":"^7.0.4","debug":"^4.3.5","growl":"^1.10.5","isexe":"^2.0.0","loupe":"^2.3.7","p-try":"^2.2.0","table":"^6.8.2","which":"^2.0.2","yargs":"^16.2.0","braces":"^3.0.3","espree":"^7.3.1","events":"^3.3.0","hasown":"^2.0.2","ignore":"^4.0.6","nanoid":"^3.1.20","rimraf":"^3.0.2","semver":"^7.6.2","terser":"^5.31.1","uri-js":"^4.4.1","wrappy":"^1.0.2","deep-is":"^0.1.4","envinfo":"^7.13.0","esprima":"^4.0.1","esquery":"^1.5.0","esutils":"^2.0.3","find-up":"^5.0.0","flatted":"^3.3.1","globals":"^13.24.0","is-glob":"^4.0.3","js-yaml":"^3.14.1","kind-of":"^6.0.3","mime-db":"^1.52.0","p-limit":"^3.1.0","pathval":"^1.1.1","pkg-dir":"^4.2.0","rechoir":"^0.7.1","regexpp":"^3.2.0","resolve":"^1.22.8","tapable":"^2.2.1","anymatch":"^3.1.3","argparse":"^1.0.10","chokidar":"^3.5.1","deep-eql":"^4.1.4","doctrine":"^3.0.0","enquirer":"^2.4.1","escalade":"^3.1.2","has-flag":"^4.0.0","inflight":"^1.0.6","inherits":"^2.0.4","isobject":"^3.0.1","p-locate":"^5.0.0","path-key":"^3.1.1","progress":"^2.0.3","punycode":"^2.3.1","readdirp":"^3.5.0","wildcard":"^2.0.1","acorn-jsx":"^5.3.2","callsites":"^3.1.0","camelcase":"^6.3.0","colorette":"^2.0.20","commander":"^2.20.3","esrecurse":"^4.3.0","interpret":"^2.2.0","is-number":"^7.0.0","js-tokens":"^4.0.0","minimatch":"^3.1.2","neo-async":"^2.6.2","picomatch":"^2.3.1","type-fest":"^0.20.2","watchpack":"^2.4.1","word-wrap":"^1.2.5","wrap-ansi":"^7.0.0","ansi-regex":"^5.0.1","clone-deep":"^4.0.1","color-name":"^1.1.4","concat-map":"^0.0.1","decamelize":"^4.0.0","estraverse":"^4.3.0","fill-range":"^7.1.1","flat-cache":"^3.2.0","is-extglob":"^2.1.1","mime-types":"^2.1.35","optionator":"^0.9.4","path-parse":"^1.0.7","picocolors":"^1.0.1","prelude-ls":"^1.2.1","slice-ansi":"^4.0.0","source-map":"^0.6.1","sprintf-js":"^1.0.3","strip-ansi":"^6.0.1","text-table":"^0.2.0","type-check":"^0.4.0","wide-align":"^1.1.3","workerpool":"^6.1.0","ansi-colors":"^4.1.3","ansi-styles":"^4.3.0","buffer-from":"^1.1.2","check-error":"^1.0.3","cross-spawn":"^7.0.3","emoji-regex":"^8.0.0","fs.realpath":"^1.0.0","glob-parent":"^5.1.2","graceful-fs":"^4.2.11","imurmurhash":"^0.1.4","jest-worker":"^27.5.1","json-buffer":"^3.0.1","locate-path":"^6.0.0","log-symbols":"^4.0.0","path-exists":"^4.0.0","randombytes":"^2.1.0","resolve-cwd":"^3.0.0","safe-buffer":"^5.2.1","type-detect":"^4.0.8","yocto-queue":"^0.1.0","ajv-keywords":"^3.5.2","astral-regex":"^2.0.0","browserslist":"^4.23.1","caniuse-lite":"^1.0.30001636","eslint-scope":"^5.1.1","eslint-utils":"^2.1.0","import-fresh":"^3.3.0","import-local":"^3.1.0","is-plain-obj":"^2.1.0","lodash.merge":"^4.6.2","merge-stream":"^2.0.0","resolve-from":"^4.0.0","schema-utils":"^3.3.0","string-width":"^4.2.3","undici-types":"^5.26.5","yargs-parser":"^20.2.4","color-convert":"^2.0.1","function-bind":"^1.1.2","get-func-name":"^2.0.2","loader-runner":"^4.3.0","node-releases":"^2.0.14","parent-module":"^1.0.1","shallow-clone":"^3.0.1","shebang-regex":"^3.0.0","webpack-merge":"^5.10.0","balanced-match":"^1.0.2","browser-stdout":"^1.3.1","glob-to-regexp":"^0.4.1","is-binary-path":"^2.1.0","is-core-module":"^2.14.0","normalize-path":"^3.0.0","supports-color":"^7.2.0","to-regex-range":"^5.0.1","yargs-unparser":"^2.0.0","assertion-error":"^1.1.0","brace-expansion":"^1.1.11","es-module-lexer":"^1.5.3","fast-deep-equal":"^3.1.3","get-caller-file":"^2.0.5","is-plain-object":"^2.0.4","lodash.truncate":"^4.4.2","natural-compare":"^1.4.0","shebang-command":"^2.0.0","webpack-sources":"^3.2.3","enhanced-resolve":"^5.17.0","fast-levenshtein":"^2.0.6","file-entry-cache":"^6.0.1","path-is-absolute":"^1.0.1","v8-compile-cache":"^2.4.0","binary-extensions":"^2.3.0","require-directory":"^2.1.1","chrome-trace-event":"^1.0.4","source-map-support":"^0.5.21","eslint-visitor-keys":"^2.1.0","fastest-levenshtein":"^1.0.16","require-from-string":"^2.0.2","strip-json-comments":"^3.1.1","electron-to-chromium":"^1.4.807","escape-string-regexp":"^4.0.0","json-schema-traverse":"^0.4.1","serialize-javascript":"^5.0.1","terser-webpack-plugin":"^5.3.10","update-browserslist-db":"^1.0.16","is-fullwidth-code-point":"^3.0.0","functional-red-black-tree":"^1.0.1","fast-json-stable-stringify":"^2.1.0","json-parse-even-better-errors":"^2.3.1","supports-preserve-symlinks-flag":"^1.0.0","json-stable-stringify-without-jsonify":"^1.0.1"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.4.1","mocha":"^8.4.0","eslint":"^7.0.0","webpack":"^5.0.0","webpack-cli":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/js-hooks_1.0.0_1718969700266_0.32782411685365576","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@ahmillat/js-hooks","version":"1.0.1","description":"A versatile JavaScript hooks system inspired by WordPress.","main":"dist/hooks.js","scripts":{"build":"webpack --mode production","test":"mocha test/hooks.test.js"},"repository":{"type":"git","url":"git+https://github.com/SneherAdor/js-hooks.git"},"keywords":["hooks","javascript","actions","filters"],"author":{"name":"Ahsanul Haque Millat"},"license":"MIT","devDependencies":{"chai":"^4.4.1","eslint":"^7.0.0","mocha":"^8.4.0","webpack":"^5.0.0","webpack-cli":"^4.0.0"},"bugs":{"url":"https://github.com/SneherAdor/js-hooks/issues"},"homepage":"https://github.com/SneherAdor/js-hooks#readme","_id":"@ahmillat/js-hooks@1.0.1","gitHead":"ab7f8e89af052a92e9d073eadb832f63079a501e","_nodeVersion":"22.3.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-ONztHtYPAYTQedfCLtub7VmJxphdMRSC1ch+huTlsFABw5gRb1qmxDz2/lP7i5k0quoRyMWH8U09NeMrmVOP6A==","shasum":"fb9dc5a14ace829d9a4d95a850f58a48828dc5f8","tarball":"https://registry.npmjs.org/@ahmillat/js-hooks/-/js-hooks-1.0.1.tgz","fileCount":9,"unpackedSize":25726,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDSZEwGAobDLE2Z11bYTl1nzSPlLDPDs/pGnc3FixOdawIgY+hf7zxkDrb5jsFriU1xb+rIGDlSA9P2euZ/I78c5rY="}]},"_npmUser":{"name":"ahmillat","email":"sneherador.sa.sa@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/js-hooks_1.0.1_1718970664436_0.9276189892283115"},"_hasShrinkwrap":false}},"time":{"created":"2024-06-21T11:35:00.121Z","modified":"2024-06-21T11:51:04.753Z","1.0.0":"2024-06-21T11:35:00.447Z","1.0.1":"2024-06-21T11:51:04.582Z"},"maintainers":[{"name":"ahmillat","email":"sneherador.sa.sa@gmail.com"}],"author":{"name":"Ahsanul Haque Millat"},"repository":{"type":"git","url":"git+https://github.com/SneherAdor/js-hooks.git"},"keywords":["hooks","javascript","actions","filters"],"license":"MIT","homepage":"https://github.com/SneherAdor/js-hooks#readme","bugs":{"url":"https://github.com/SneherAdor/js-hooks/issues"},"readme":"\r\n# JavaScript Hooks System\r\n\r\nA versatile JavaScript hooks system inspired by WordPress, designed to add and remove actions and filters effortlessly. This library empowers developers to hook into core functions and modify their behavior, facilitating the creation of extensible JavaScript applications. Ideal for developing plugins or modules that can be seamlessly integrated or removed, enhancing the flexibility and maintainability of your codebase.\r\n\r\n## Features\r\n- **addAction(tag, callback, priority):** Register a new action for a specific tag.\r\n- **addFilter(tag, callback, priority):** Register a new filter for a specific tag.\r\n- **removeAction(tag, callback):** Remove a previously registered action.\r\n- **removeFilter(tag, callback):** Remove a previously registered filter.\r\n- **doAction(tag, options):** Execute all actions associated with a specific tag.\r\n- **applyFilters(tag, value, options):** Apply all filters associated with a specific tag to a value.\r\n- **hasAction(tag):** Check if any actions are registered for a specific tag.\r\n- **hasFilter(tag):** Check if any filters are registered for a specific tag.\r\n\r\n## Installation\r\n\r\nYou can include this library directly in your project by downloading the source code from this repository and adding it to your project.\r\n\r\n```html\r\n<script src=\"path/to/hooks.js\"></script>\r\n```\r\n\r\nAlternatively, you can use npm to install it:\r\n\r\n```bash\r\nnpm i @ahmillat/js-hooks\r\n```\r\n\r\n## Usage\r\n\r\nBelow is a basic example demonstrating how to use this library.\r\n\r\n### Example\r\n\r\n```javascript\r\n\r\n// Add an action\r\naddAction('init', () => {\r\n    console.log('Initialization action called');\r\n});\r\n\r\n// Add a filter\r\naddFilter('content', (content) => {\r\n    return content.toUpperCase();\r\n});\r\n\r\n// Check if an action is registered\r\nif (hasAction('init')) {\r\n    console.log('Init action is registered');\r\n}\r\n\r\n// Check if a filter is registered\r\nif (hasFilter('content')) {\r\n    console.log('Content filter is registered');\r\n}\r\n\r\n// Execute an action\r\ndoAction('init');\r\n\r\n// Apply a filter\r\nconst filteredContent = applyFilters('content', 'Hello World');\r\nconsole.log(filteredContent);  // Outputs: HELLO WORLD\r\n\r\n// Remove the action\r\nremoveAction('init', callback);\r\n\r\n// Remove the filter\r\nremoveFilter('content', callback);\r\n```\r\n\r\n## API Documentation\r\n\r\n### `addAction(tag, callback, priority = 10)`\r\nRegisters a new action callback for a specific tag.\r\n\r\n- **tag**: The tag specified by `doAction`.\r\n- **callback**: The callback function to call when `doAction` is executed.\r\n- **priority**: The order in which to call the callbacks. Lower numbers correspond to earlier execution. Default is 10.\r\n\r\n### `addFilter(tag, callback, priority = 10)`\r\nRegisters a new filter callback for a specific tag.\r\n\r\n- **tag**: The tag specified by `applyFilters`.\r\n- **callback**: The callback function to call when `applyFilters` is executed.\r\n- **priority**: The order in which to call the callbacks. Lower numbers correspond to earlier execution. Default is 10.\r\n\r\n### `removeAction(tag, callback)`\r\nRemoves a previously registered action callback for a specific tag.\r\n\r\n- **tag**: The tag specified by `doAction`.\r\n- **callback**: The callback function to remove.\r\n\r\n### `removeFilter(tag, callback)`\r\nRemoves a previously registered filter callback for a specific tag.\r\n\r\n- **tag**: The tag specified by `applyFilters`.\r\n- **callback**: The callback function to remove.\r\n\r\n### `doAction(tag, options)`\r\nExecutes all action callbacks registered for a specific tag.\r\n\r\n- **tag**: The tag of the registered actions to execute.\r\n- **options**: Optional JavaScript object to pass to the callbacks.\r\n\r\n### `applyFilters(tag, value, options)`\r\nApplies all filter callbacks registered for a specific tag to a value.\r\n\r\n- **tag**: The tag of the registered filters to apply.\r\n- **value**: The value to be filtered.\r\n- **options**: Optional JavaScript object to pass to the callbacks.\r\n\r\n### `hasAction(tag)`\r\nChecks if any actions are registered for a specific tag.\r\n\r\n- **tag**: The tag to check for registered actions.\r\n- **returns**: `true` if there are any actions registered for the tag, `false` otherwise.\r\n\r\n### `hasFilter(tag)`\r\nChecks if any filters are registered for a specific tag.\r\n\r\n- **tag**: The tag to check for registered filters.\r\n- **returns**: `true` if there are any filters registered for the tag, `false` otherwise.\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License.\r\n\r\n## Acknowledgments\r\n\r\nInspired by the WordPress hooks system.\r\n\r\n---\r\n\r\nFeel free to open issues or pull requests if you have any questions or suggestions!","readmeFilename":"README.md"}