{"id":17095114,"url":"https://github.com/harunurhan/idlejs","last_synced_at":"2025-08-15T09:32:44.326Z","repository":{"id":27314865,"uuid":"113328946","full_name":"harunurhan/idlejs","owner":"harunurhan","description":"Execute stuff when user is idle or interactive","archived":false,"fork":false,"pushed_at":"2024-06-18T02:56:58.000Z","size":257,"stargazers_count":37,"open_issues_count":4,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-22T14:48:21.384Z","etag":null,"topics":["idle","interactive","no-dependencies","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/harunurhan.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}},"created_at":"2017-12-06T14:50:58.000Z","updated_at":"2024-08-31T19:22:46.000Z","dependencies_parsed_at":"2023-01-14T07:45:25.657Z","dependency_job_id":"40b36f7f-7052-4df8-bce5-1416f4fbf4d7","html_url":"https://github.com/harunurhan/idlejs","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":"0.10526315789473684","last_synced_commit":"1f3b172a669e207115d0631a415568cc467563e9"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harunurhan%2Fidlejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harunurhan%2Fidlejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harunurhan%2Fidlejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harunurhan%2Fidlejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harunurhan","download_url":"https://codeload.github.com/harunurhan/idlejs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229906183,"owners_count":18142456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["idle","interactive","no-dependencies","typescript"],"created_at":"2024-10-14T14:25:50.421Z","updated_at":"2024-12-16T04:07:02.898Z","avatar_url":"https://github.com/harunurhan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# idlejs\n\nExecute a function only when certain events on certain target element have or have not occured within given timeout.\n\nIt's simple, configurable, typescript friendly and has an easy chainable API.\n\n### Install\n\n```bash\nyarn add idlejs\n\nnpm install --save idlejs\n```\n\n### v2 to v3\n\n#### Change imports from `idlejs/dist` to `idlejs`\n\n```js\nimport { ... } from 'idjejs' \n```\n\n### Idle\n\nExcutes the callback function (`do`) when **none** of the specified events have occurred within given time, in other words when user is idle. \n\n#### Usage\n\n```typescript\nimport { Idle } from 'idlejs';\n\n// with predefined events on `document`\nconst idle = new Idle()\n  .whenNotInteractive()\n  .within(5)\n  .do(() =\u003e logoutUser())\n  .start();\n\n// another example with custom events which are useful if events aren't bubbling up to the document\nconst idle = new Idle()\n  .whenNot([{\n    events: ['click', 'hover'],\n    target: buttonEl,\n  },\n  {\n    events: ['click', 'input'],\n    target: inputEl,\n  },\n  ])\n  .whenNotInteractive()\n  .within(10)\n  .do(logoutUser)\n  .start();\n```\n\nFor more features or examples please check the [tests](./src/idle.spec.ts) and [source](./src/idle.ts) code.\n\n### NotIdle\n\nExecutes the callback function (`do`), if at least **one** of the specified events have occured within given time, in other words when user is not idle or interactive.\n\n#### Usage\n\n```typescript\nimport { NotIdle } from 'idlejs';\n\n// with predefined events on `document`\nconst idle = new Idle()\n  .whenInteractive()\n  .within(10)\n  .do(() =\u003e log('user was active in the last 10 minutes'))\n  .start();\n\n// another example with custom events which are useful if events aren't bubbling up to the `document`\nconst notIdle = new NotIdle()\n  .when([{\n    events: ['click', 'hover'],\n    target: buttonEl,\n  },\n  {\n    events: ['click', 'input'],\n    target: inputEl,\n  },\n  ])\n  .whenInteractive()\n  .within(10)\n  .do(() =\u003e log('user was active in the last 10 minutes'))\n  .start();\n```\n\nFor more features or examples please check the [tests](./src/not-idle.spec.ts) and [source](./src/not-idle.ts) code.\n\n### Setting time\n\nSecond parameter of `within` is time unit in miliseconds, by default 60000 (a minute).\n\n```typescript\n// will trigger if nothing happens for 5 minutes\nnew Idle()\n  .within(5)\n\n// will trigger if nothing happens for 5 seconds\nnew Idle()\n  .within(5, 1000)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharunurhan%2Fidlejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharunurhan%2Fidlejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharunurhan%2Fidlejs/lists"}