{"id":16698181,"url":"https://github.com/arlac77/etag-cache-leveldb","last_synced_at":"2025-05-16T07:34:03.475Z","repository":{"id":37793942,"uuid":"495042653","full_name":"arlac77/etag-cache-leveldb","owner":"arlac77","description":"etag cache based on leveldb","archived":false,"fork":false,"pushed_at":"2025-05-08T18:06:48.000Z","size":1750,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-08T19:53:58.989Z","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":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arlac77.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":"2022-05-22T11:39:16.000Z","updated_at":"2025-05-08T15:39:27.000Z","dependencies_parsed_at":"2023-10-15T23:27:48.897Z","dependency_job_id":"cfa4784d-65d3-458d-a109-f80fc6fc569d","html_url":"https://github.com/arlac77/etag-cache-leveldb","commit_stats":{"total_commits":218,"total_committers":3,"mean_commits":72.66666666666667,"dds":0.2018348623853211,"last_synced_commit":"46f38f24f76c03e460a3844b94e52d407b038ddc"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Fetag-cache-leveldb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Fetag-cache-leveldb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Fetag-cache-leveldb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arlac77%2Fetag-cache-leveldb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arlac77","download_url":"https://codeload.github.com/arlac77/etag-cache-leveldb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254488874,"owners_count":22079512,"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-12T17:51:04.551Z","updated_at":"2025-05-16T07:34:03.468Z","avatar_url":"https://github.com/arlac77.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/etag-cache-leveldb.svg)](https://www.npmjs.com/package/etag-cache-leveldb)\n[![License](https://img.shields.io/badge/License-0BSD-blue.svg)](https://spdx.org/licenses/0BSD.html)\n[![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\\\u0026label\\\u0026labelColor=blue\\\u0026color=555555)](https://typescriptlang.org)\n[![bundlejs](https://deno.bundlejs.com/?q=etag-cache-leveldb\\\u0026badge=detailed)](https://bundlejs.com/?q=etag-cache-leveldb)\n[![downloads](http://img.shields.io/npm/dm/etag-cache-leveldb.svg?style=flat-square)](https://npmjs.org/package/etag-cache-leveldb)\n[![GitHub Issues](https://img.shields.io/github/issues/arlac77/etag-cache-leveldb.svg?style=flat-square)](https://github.com/arlac77/etag-cache-leveldb/issues)\n[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Farlac77%2Fetag-cache-leveldb%2Fbadge\\\u0026style=flat)](https://actions-badge.atrox.dev/arlac77/etag-cache-leveldb/goto)\n[![Styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![Known Vulnerabilities](https://snyk.io/test/github/arlac77/etag-cache-leveldb/badge.svg)](https://snyk.io/test/github/arlac77/etag-cache-leveldb)\n[![Coverage Status](https://coveralls.io/repos/arlac77/etag-cache-leveldb/badge.svg)](https://coveralls.io/github/arlac77/etag-cache-leveldb)\n\n# etag-cache-leveldb\n\netag cache based on leveldb\n\n# example\n\n```js\nimport levelup from \"levelup\";\nimport leveldown from \"leveldown\";\nimport { ETagCacheLevelDB } from \"etag-cache-leveldb\";\n\nconst someDirectory = \"/tmp\";\nconst db = await levelup(leveldown(someDirectory));\nconst cache = new ETagCacheLevelDB(db);\n\nconst url = \"https://api.github.com/\";\n\nconst response = await fetch(url);\n\nawait cache.storeResponse(response);\n\n// later\n\nconst headers = {};\n\nawait cache.addHeaders(url, headers); // fill in etag header\n\nconst responseWithETag = await fetch(url, { headers });\nconst cachedResponse = await cache.loadResponse(responseWithETag);\n```\n\n# API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### Table of Contents\n\n*   [ETagCacheLevelDB](#etagcacheleveldb)\n    *   [Parameters](#parameters)\n    *   [addHeaders](#addheaders)\n        *   [Parameters](#parameters-1)\n    *   [statistics](#statistics)\n    *   [storeResponse](#storeresponse)\n        *   [Parameters](#parameters-2)\n    *   [loadResponse](#loadresponse)\n        *   [Parameters](#parameters-3)\n*   [rawTagData](#rawtagdata)\n    *   [Parameters](#parameters-4)\n\n## ETagCacheLevelDB\n\nStores etags and bodies into leveldb.\nReconstructs response with body if etag or url matches.\nWill store in the cache:\nurl : etag\netag : body\n\n### Parameters\n\n*   `db` \u0026#x20;\n\n### addHeaders\n\nAdds the \"If-None-Match\" header if etag is found for the url.\n\n#### Parameters\n\n*   `url` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [URL](https://developer.mozilla.org/docs/Web/API/URL/URL))**\u0026#x20;\n*   `headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u003c[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)\u003e** true if etag was found in cache and header has been added\n\n### statistics\n\nDeliver statisics data.\n\nReturns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**\u0026#x20;\n\n### storeResponse\n\nStores response in the cache.\nTwo entries are stored:\n\n*   url : etag\n*   etag : body\n\n#### Parameters\n\n*   `response` **[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)** as produced by fetch\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\\u003cany\u003e**\u0026#x20;\n\n### loadResponse\n\nConstructs a new Response feed from the cache if a matching etag is found in the cache.\n\n#### Parameters\n\n*   `response` **[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)** as provided by fetch\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u003c[Response](https://developer.mozilla.org/docs/Web/Guide/HTML/HTML5)\u003e**\u0026#x20;\n\n## rawTagData\n\nStrips away etag flags (weak and the like)\n\n### Parameters\n\n*   `etag` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | null)**\u0026#x20;\n\nReturns **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** raw etag\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farlac77%2Fetag-cache-leveldb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farlac77%2Fetag-cache-leveldb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farlac77%2Fetag-cache-leveldb/lists"}