{"id":28491619,"url":"https://github.com/apsonex/js-utils","last_synced_at":"2026-05-01T16:32:07.992Z","repository":{"id":297474865,"uuid":"996453571","full_name":"apsonex/js-utils","owner":"apsonex","description":"Utility functions for DOM manipulation, string handling, and client-side caching in modern JavaScript","archived":false,"fork":false,"pushed_at":"2025-07-14T00:55:13.000Z","size":215,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-08T14:53:18.893Z","etag":null,"topics":["apsonex","caching","dom","esmodule","javascript","js-utils","manipulation","npm-package","string","utilities","vite"],"latest_commit_sha":null,"homepage":"https://apsonex.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apsonex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-05T01:17:40.000Z","updated_at":"2025-07-14T00:55:16.000Z","dependencies_parsed_at":"2025-06-05T17:35:45.638Z","dependency_job_id":"afe79071-1685-407f-b0e6-65a3671756bf","html_url":"https://github.com/apsonex/js-utils","commit_stats":null,"previous_names":["apsonex/js-utils"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/apsonex/js-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apsonex%2Fjs-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apsonex%2Fjs-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apsonex%2Fjs-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apsonex%2Fjs-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apsonex","download_url":"https://codeload.github.com/apsonex/js-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apsonex%2Fjs-utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32505004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apsonex","caching","dom","esmodule","javascript","js-utils","manipulation","npm-package","string","utilities","vite"],"created_at":"2025-06-08T08:07:53.640Z","updated_at":"2026-05-01T16:32:07.980Z","avatar_url":"https://github.com/apsonex.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @apsonex/js-utils\n\n\u003e A small, useful utility collection for JavaScript/ESM projects — includes string helpers, DOM utilities, a localStorage-based cache, event communication layer, and pipeline processing.\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install @apsonex/js-utils\n```\n\nOr using Yarn:\n\n```bash\nyarn add @apsonex/js-utils\n```\n\n---\n\n## 🛠 Usage\n\n```js\nimport {\n  JsCache,\n  str,\n  bodyScrollEnable,\n  bodyScrollDisable,\n  isIframe,\n  loadScript,\n  loadStyle,\n  Events,\n  Pipeline,\n} from '@apsonex/js-utils';\n```\n\n---\n\n## 📚 Features\n\n### 🔡 String Utilities (`str`)\nChainable utility class for common string operations.\n\n```js\nstr(\"hello world\").kebabCase().toString(); // \"hello-world\"\nstr(\"some/filename.txt\").afterLast(\"/\").toString(); // \"filename.txt\"\nstr(\"html content\").minifyHtml(); // removes whitespace, comments\nstr(\"HELLO_WORLD\").sentenseCase().toString(); // \"Hello World\"\n```\n\n**Chainable Methods:**\n\n- `after`, `afterLast`, `before`, `beforeLast`\n- `kebabCase`, `camelCase`, `snakeCase`, `slug`, `plural`, `singular`\n- `screamCase`, `titleCase`, `capitalizeWords`\n- `replaceFirst`, `replaceLast`, `replaceArray`\n- `limit`, `words`, `startCase`, `finish`\n- `contains`, `containsAll`, `is`, `startsWith`, `endsWith`\n- `title`, `minifyHtml`, `explode`\n\n**Notable Additions:**\n- `sentenseCase()`: Transforms strings like `\"HELLO_WORLD\"` into `\"Hello World\"`\n- `capitalizeWords()`: Capitalizes the first letter of each word\n\n---\n\n### 📦 Local Cache (`JsCache`)\nSimple localStorage cache with TTL support.\n\n```js\nconst cache = new JsCache().init({ prefix: 'my_app:' });\n\ncache.put('user', { name: 'John' }, '10m');\ncache.remember('settings', '1hr', () =\u003e fetchSettings());\n```\n\nTTL formats:\n- `60s`, `10m`, `1hr`, `1d`, `1mo`, `1yr`, or numeric seconds\n\nMethods:\n- `put(key, value, ttl)`\n- `remember(key, ttl, fallback)`\n- `get(key)`\n- `has(key)`\n- `forget(key)`\n\n---\n\n### 🧩 DOM Utilities\nUseful browser DOM helpers.\n\n```js\nbodyScrollDisable(); // disables body scroll\nbodyScrollEnable();  // re-enables scroll\n\nisIframe(); // true if in an iframe\n```\n\n---\n\n### 📜 Dynamic Script \u0026 Style Loaders\nLoad external assets with callbacks and deduplication.\n\n```js\nawait loadScript('https://example.com/script.js', {\n  type: 'module',\n  onLoad: () =\u003e console.log('loaded'),\n  onError: (err) =\u003e console.error(err),\n});\n\nawait loadStyle('https://example.com/style.css', {\n  media: 'all',\n});\n```\n\nFeatures:\n- Prevents duplicate loading\n- Supports `onLoad`, `onError`, `crossorigin`, `type`, etc.\n\n---\n\n### 📡 Events System (`Events`)\nHandles safe cross-window event communication (parent ↔ iframe) with unified API.\n\n```js\nconst triggers = ['ready', 'parentReady'];\n\nconst events = new Events()\n  .resolveIframeVia(() =\u003e store().iframe)\n  .triggers(triggers)\n  .init();\n\nevents.ready.dispatch({ hello: 'world' });\nevents.ready.listen((data) =\u003e console.log('Received:', data));\n```\n\nAPI:\n- `.setIframe(iframeElement)`\n- `.resolveIframeVia(() =\u003e iframeElement)`\n- `.triggers(['eventOne', 'eventTwo'])`\n- `.init()` returns trigger handlers\n\nEach trigger provides:\n- `.dispatch(data)`\n- `.listen(callback)`\n\n---\n\n### 🔁 Pipeline Processor (`Pipeline`)\nChain synchronous or async tasks for consistent data flow.\n\n```js\nconst pipeline = new Pipeline()\n  .pipe([\n    (data) =\u003e data + 1,\n    async (data) =\u003e data * 2,\n    (data) =\u003e `Final: ${data}`,\n  ]);\n\npipeline.process(2).then(console.log); // Final: 6\n```\n\nMethods:\n- `pipe(fn | fn[])` — add processing steps\n- `empty()` — reset pipeline\n- `process(input)` — run through all stages\n\nEach stage can be:\n- A function `(input) =\u003e output`\n- A static value that skips input\n\n---\n\n## 🧪 Build\n\n```bash\nnpm run build\n```\n\nOutputs:\n- ES Module (`dist/*.es.js`)\n- UMD Module (`dist/*.umd.js`)\n\n---\n\n## 📄 License\n\nMIT License © [Apsonex Inc.](https://apsonex.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapsonex%2Fjs-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapsonex%2Fjs-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapsonex%2Fjs-utils/lists"}