{"id":22081570,"url":"https://github.com/vunb/kiper","last_synced_at":"2025-07-24T14:32:46.436Z","repository":{"id":69291454,"uuid":"95101798","full_name":"vunb/kiper","owner":"vunb","description":"Keep objects available everywhere in nodejs application","archived":false,"fork":false,"pushed_at":"2017-06-28T09:19:50.000Z","size":21,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-28T18:12:21.258Z","etag":null,"topics":["key-value-store","map","nodejs","observables","observer"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vunb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-06-22T10:01:55.000Z","updated_at":"2023-12-01T13:15:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"88b6691a-55ec-4058-97b6-63c8e6af7072","html_url":"https://github.com/vunb/kiper","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"28b5c31231a2a4f62fab3b29c1a1bec006536ade"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/vunb/kiper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vunb%2Fkiper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vunb%2Fkiper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vunb%2Fkiper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vunb%2Fkiper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vunb","download_url":"https://codeload.github.com/vunb/kiper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vunb%2Fkiper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266855914,"owners_count":23995582,"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","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"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":["key-value-store","map","nodejs","observables","observer"],"created_at":"2024-11-30T23:24:36.525Z","updated_at":"2025-07-24T14:32:46.423Z","avatar_url":"https://github.com/vunb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kiper\nKeep objects available everywhere in nodejs application\n\n[![npm version](https://img.shields.io/npm/v/kiper.svg?style=flat)](https://www.npmjs.com/package/kiper)\n[![Travis](https://travis-ci.org/vunb/kiper.svg?branch=master)](https://travis-ci.org/vunb/kiper)\n\nHow to use\n==========\n\nFirst you need to install `kiper` using npm:\n\n```bash\nnpm install kiper --save\n```\n\nThen, use kiper in your project:\n\n```js\nconst kiper = require('kiper');\n\n// somewhere keep an asset\nkiper.keep('foo', 'bar');\n\n// somewhere you got it back\nlet value = kiper.get('foo');\nconsole.log(value);\n\n```\n\nMain features\n=============\n\n* Keep objects and cache them in memory\n* Keep an object with a timeout (TTL - time to live)\n* Observe key if its value has any changed\n* Add/listen a custom event\n\nUsecases\n========\n\n* Cache object\n* Observing the changes to an object\n* Send and receive messages through events\n* Create agents and manage them. Such as: `Chatbot manager`, `Dialog manager`, ...\n* Etc, ...\n\nAPI Usage\n=========\n\nClass: Kiper(options)\n=======================\n\u003e The `Kiper` class is defined and exposed by the module `kiper`  \n\u003e Added in: `v0.0.1`  \n\u003e Options: \n\u003e * **ttl**: (default: 0) - time to live in milliseconds. 0 = infinity\n\u003e * **checkPeriod**: (default: 600) - duration to check timeout on key has expired.\n\u003e * **checkUsage**: (default: true) - check the last time usage\n\n```js\n// create new instance of Kiper\nconst kiper = require('kiper').Kiper(options);\n```\n\nMethod: `.keep(key: string, value: object)`\n-------------------------------\n\n\u003e Keep an object in kiper  \n\u003e Added in: `v0.0.1`  \n\u003e Alias: `set`\n\n```js\nkiper.keep('foo', 'bar');\n```\n\nMethod: `.keep(key: string, value: object, ttl: int, timeout: function)`\n-------------------------------\n\n\u003e Keep an object for a period of time  \n\u003e Added in: `v0.1.0`  \n\u003e Alias: `set`\n\n```js\nkiper.keep('foo', 'bar', 1000, console.log);\n// output: bar foor\n```\n\nMethod: `.get(key: string)`\n-------------------------------\n\n\u003e Get an object from kiper  \n\u003e Added in: `v0.0.1`\n\n```js\nkiper.get('foo');\n// returns: bar\n```\n\nMethod: `.get(validator: function)`\n-------------------------------\n\n\u003e Get an object from kiper by pass a validator function  \n\u003e Added in: `v0.0.2`\n\n```js\nkiper.get((value, key) =\u003e value === 'bar');\n// returns: bar\n```\n\nMethod: `.remove(key: string)`\n-------------------------------\n\n\u003e Remove an object out of kiper  \n\u003e Added in: `v0.1.0`  \n\n```js\nkiper.remove('foo');\n// returns: bar\n```\n\nMethod: `.retire()`\n-------------------------------\n\n\u003e Stop interval checking, free memory and release objects  \n\u003e Added in: `v0.1.0`  \n\n```js\nkiper.retire();\n```\n\nMethod: `.touch(key)`\n-------------------------------\n\n\u003e Repair the last time usage  \n\u003e Added in: `v1.0.0`  \n\n```js\nkiper.touch('foo');\n```\n\nMethod: `.watch(key, callback)`\n-------------------------------\n\n\u003e Watch a key, if its value changes then a callback will be called  \n\u003e Added in: `v1.0.0`  \n\n```js\n// keep an asset and return an obserable object \nlet baz = kiper.keep('baz', {\n    gold: 1000\n});\n\n// watch the key\nkiper.watch('baz', (obj, oldVal, propkey, type) =\u003e {\n    console.log('change info:', obj, oldVal, propkey, type);\n    // change info: { gold: 999 } 1000 gold update\n    // change info: { silver: 1000 } undefined silver add\n    // change info: {} 999 gold delete\n});\n\n// baz lost one gold\nbaz.gold = 999\n// baz has new silvers\nbaz.silver = 1000\n// baz lost all golds\ndelete baz.gold\n```\n\nMethod: `.on(event, listener)`\n-------------------------------\n\n\u003e Listen an event which emit from kiper  \n\u003e Added in: `v1.0.0`  \n\n```js\nkiper.keep('foo', 'bar', 1000);\nkiper.on('expired', (value, key) =\u003e {\n    console.log('A timeout on key has expired', value, key);\n    // A timeout on key has expired bar foo\n})\n```\n\nMethod: `.once(event, listener)`\n-------------------------------\n\n\u003e Listen an event once which emit from kiper  \n\u003e Added in: `v1.0.0`  \n\n```js\nkiper.keep('foo', 'bar', 1000);\nkiper.once('expired', (value, key) =\u003e {\n    console.log('A timeout on key has expired', value, key);\n    // A timeout on key has expired bar foo\n})\n```\n\nLicense\n=======\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvunb%2Fkiper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvunb%2Fkiper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvunb%2Fkiper/lists"}