{"id":18769659,"url":"https://github.com/caojianping/tsx-cookie","last_synced_at":"2025-04-13T07:31:33.869Z","repository":{"id":57286742,"uuid":"206047236","full_name":"caojianping/tsx-cookie","owner":"caojianping","description":"Cookie的TypeScript封装，提供通用的API方法，同时支持泛型方法。","archived":false,"fork":false,"pushed_at":"2023-03-30T06:46:27.000Z","size":8,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-14T01:17:49.210Z","etag":null,"topics":["cookie","getitem","jts-cookie","setitem","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/caojianping.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}},"created_at":"2019-09-03T10:06:02.000Z","updated_at":"2023-08-25T01:32:54.000Z","dependencies_parsed_at":"2022-09-10T03:32:39.411Z","dependency_job_id":null,"html_url":"https://github.com/caojianping/tsx-cookie","commit_stats":null,"previous_names":["caojianping/jts-cookie"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caojianping%2Ftsx-cookie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caojianping%2Ftsx-cookie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caojianping%2Ftsx-cookie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caojianping%2Ftsx-cookie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caojianping","download_url":"https://codeload.github.com/caojianping/tsx-cookie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223573757,"owners_count":17167370,"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":["cookie","getitem","jts-cookie","setitem","typescript"],"created_at":"2024-11-07T19:16:32.971Z","updated_at":"2024-11-07T19:16:36.322Z","avatar_url":"https://github.com/caojianping.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tsx-cookie\n\nCookie的TypeScript封装，提供通用的API方法，同时支持泛型方法。\n\n## Installing\nUsing npm:\n```bash\n$ npm install tsx-cookie\n```\n\n## Example\n```ts\nimport Cookie, {ICookieOption} from 'tsx-cookie';\n\nconst name1 = 'cookie_number';\nconst value1 = 666888;\nconst expires1 = 3600 * 1000 * 2;// 过期时间\nCookie.setItem\u003cnumber\u003e(name1, value1, expires1);// return true/false;\nCookie.getItem\u003cnumber\u003e(name1);// return 666888/null;\nCookie.removeItem(name1);// return true/false;\n\nconst name2 = 'cookie_string';\nconst value2 = 'hello world';\nconst expires2 = 3600 * 1000 * 2;\nCookie.setItem\u003cstring\u003e(name2, value2, expires2);// return true/false;\nCookie.getItem\u003cstring\u003e(name2);// return 'hello world'/null;\nCookie.removeItem(name2);// return true/false;\n\nCookie.getAllKeys();// return ['cookie_number', 'cookie_string']\n```\n\n## API\n```ts\n/**\n * cookie选项接口\n */\nexport interface ICookieOption {\n  // 名称\n  name: string;\n\n  // 数值\n  value: any;\n\n  // 过期时间，单位：毫秒\n  expires?: number;\n\n  // 路径\n  path?: string;\n}\n```\n##### Cookie.setItem\u003cT\u003e(name: string, value: T [, expires: number] [, path: string]): boolean\n##### Cookie.setItems(options: Array\u003cICookieOption\u003e): boolean\n##### Cookie.getItem\u003cT\u003e(name: string): T | null\n##### Cookie.getAllKeys(): Array\u003cstring\u003e\n##### Cookie.removeItem(name: string[, path: string]): boolean\n##### Cookie.clear([, path: string]): void\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaojianping%2Ftsx-cookie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaojianping%2Ftsx-cookie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaojianping%2Ftsx-cookie/lists"}