{"id":16641958,"url":"https://github.com/artskydj/state-holder","last_synced_at":"2026-04-28T04:34:55.288Z","repository":{"id":27601645,"uuid":"31085085","full_name":"ArtskydJ/state-holder","owner":"ArtskydJ","description":"Basic getter and setter for arbitrary data","archived":false,"fork":false,"pushed_at":"2016-01-02T17:15:51.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-19T09:38:11.843Z","etag":null,"topics":[],"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/ArtskydJ.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}},"created_at":"2015-02-20T21:01:59.000Z","updated_at":"2016-01-02T17:16:01.000Z","dependencies_parsed_at":"2022-08-01T11:07:33.867Z","dependency_job_id":null,"html_url":"https://github.com/ArtskydJ/state-holder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArtskydJ%2Fstate-holder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArtskydJ%2Fstate-holder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArtskydJ%2Fstate-holder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ArtskydJ%2Fstate-holder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ArtskydJ","download_url":"https://codeload.github.com/ArtskydJ/state-holder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243165109,"owners_count":20246719,"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":[],"created_at":"2024-10-12T07:48:23.260Z","updated_at":"2025-12-27T07:35:02.953Z","avatar_url":"https://github.com/ArtskydJ.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"state-holder\r\n============\r\n\r\n\u003e Basic getter and setter for arbitrary data\r\n\r\n[![Build Status](https://travis-ci.org/ArtskydJ/state-holder.svg)](https://travis-ci.org/ArtskydJ/state-holder)\r\n\r\n# source code\r\n\r\nI think the best way to describe this module is to show you its source code:\r\n\r\n```js\r\nmodule.exports = function StateHolder(thing) {\r\n\treturn {\r\n\t\tget: function get() { return thing },\r\n\t\tset: function set(x) { return thing = x }\r\n\t}\r\n}\r\n```\r\n\r\nThat's it! Short and sweet!\r\n\r\n# why\r\n\r\nPerhaps you're saying \"This is the dumbest module I've ever seen!\" Well, maybe it is, but it solved a problem for me. You can pass either `state.set` or `state.get` to another function, and it can only set data or get data, but not vise versa.\r\n\r\n# example\r\n\r\nAnd a quick example of how to use it:\r\n\r\n```js\r\nvar StateHolder = require('state-holder')\r\n\r\nvar state = StateHolder( 'hello' )\r\nstate.get() // =\u003e 'hello'\r\n\r\nstate.set() // =\u003e undefined\r\nstate.get() // =\u003e undefined\r\n\r\nstate.set('world') // =\u003e 'world'\r\nstate.get() // =\u003e 'world'\r\n```\r\n\r\n# api\r\n\r\n```js\r\nvar StateHolder = require('state-holder')\r\n```\r\n\r\n## `var state = StateHolder( [thing] )`\r\n\r\nCan be called with or without `new`.\r\n\r\nThe state is set to the value of `thing`. If `thing` is omitted, the state is set to `undefined`.\r\n\r\n## `var thing = state.get()`\r\n\r\nReturns the state.\r\n\r\n## `state.set( [thing] )`\r\n\r\nThe state is set to the value of `thing`. If `thing` is omitted, the state is set to `undefined`. Whatever the state ends up being set to is returned.\r\n\r\n# install\r\n\r\n```bash\r\nnpm install state-holder\r\n```\r\n\r\n# license\r\n\r\n[VOL](http://veryopenlicense.com)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartskydj%2Fstate-holder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartskydj%2Fstate-holder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartskydj%2Fstate-holder/lists"}