{"id":22295492,"url":"https://github.com/mrodrig/deeks","last_synced_at":"2025-07-29T01:32:05.464Z","repository":{"id":33395510,"uuid":"158056280","full_name":"mrodrig/deeks","owner":"mrodrig","description":"Retrieve all keys and nested keys from objects and arrays of objects.","archived":false,"fork":false,"pushed_at":"2024-07-13T02:09:35.000Z","size":263,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-20T00:55:07.418Z","etag":null,"topics":["deep","document","extraction","hacktoberfest","javascript","json","key","object","parser"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/mrodrig.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":"2018-11-18T06:24:57.000Z","updated_at":"2024-07-16T12:01:04.000Z","dependencies_parsed_at":"2023-01-15T00:44:31.053Z","dependency_job_id":"fd618269-7062-4799-b472-6a24a45c3a3c","html_url":"https://github.com/mrodrig/deeks","commit_stats":{"total_commits":69,"total_committers":6,"mean_commits":11.5,"dds":0.6086956521739131,"last_synced_commit":"b902c48b54fb68afcb4aadfecea7e63c4cefc5d0"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/mrodrig/deeks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrodrig%2Fdeeks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrodrig%2Fdeeks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrodrig%2Fdeeks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrodrig%2Fdeeks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrodrig","download_url":"https://codeload.github.com/mrodrig/deeks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrodrig%2Fdeeks/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266953023,"owners_count":24011515,"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-25T02:00:09.625Z","response_time":70,"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":["deep","document","extraction","hacktoberfest","javascript","json","key","object","parser"],"created_at":"2024-12-03T17:42:20.331Z","updated_at":"2025-07-29T01:32:05.021Z","avatar_url":"https://github.com/mrodrig.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# deeks - Deep Object Key Extraction\n\n[![NPM version](https://img.shields.io/npm/v/deeks.svg)](https://www.npmjs.org/package/deeks)\n[![Downloads](https://img.shields.io/npm/dm/deeks)](https://www.npmjs.org/package/deeks)\n[![Minzipped Size](https://img.shields.io/bundlephobia/minzip/deeks)](https://bundlephobia.com/result?p=deeks)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/mrodrig/deeks/automated-tests-workflow.yml)](https://github.com/mrodrig/deeks/actions/workflows/automated-tests-workflow.yml)\n[![Coverage Status](https://coveralls.io/repos/github/mrodrig/deeks/badge.svg?branch=main)](https://coveralls.io/github/mrodrig/deeks?branch=main)\n[![Typings](https://img.shields.io/npm/types/deeks)](https://www.npmjs.org/package/deeks)\n\n**Retrieve all keys and nested keys from objects and arrays of objects.**\n\n## Installing\n\n```bash\nnpm install --save deeks\n```\n\nExample: \n```javascript\nconst { deepKeys } = require('deeks');\n// Alternatively:\n// import { deepKeys } from 'deeks';\n\nlet generatedKeys = deepKeys({\n\tmake: 'Nissan',\n\tmodel: 'GT-R',\n\ttrim: 'NISMO',\n\tspecifications: [\n\t    {mileage: 10},\n\t    {cylinders: 6}\n\t]\n}, {\n    expandArrayObjects: true,\n    ignoreEmptyArraysWhenExpanding: true\n});\n// =\u003e ['make', 'model', 'trim', 'specifications.mileage', 'specifications.cylinders']\n```\n\n## API\n\n### deepKeys \n\n`deepKeys(object, options)`\n\nReturns all keys in an object, even if they're nested several layers deep. \nThe array of keys that is returned can then be used with the \n[`doc-path`](https://github.com/mrodrig/doc-path) module to get and set values \nat a specific key path.\n\nOptions (optional):\n- arrayIndexesAsKeys - `Boolean` (Default `false`) - Should array indexes be used as keys in the generated path?\n\t- Example:\n\t```json\n\t[\n\t\t{\n\t\t\t\"list\": [\n\t\t\t\t{\n\t\t\t\t\t\"a\": 1\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t\"a\": 2\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t]\n\t```\n\t- arrayIndexesAsKeys = `false` results in: `['list.a']`\n\t- arrayIndexesAsKeys = `true` results in: `['list.0.a', 'list.1.a']`\n- expandNestedObjects - `Boolean` (Default: `true`) - Should nested objects appearing in the provided object also be expanded, such asthat keys appearing in those objects are extracted and included in the returned key path list?\n\t- Example:\n\t```json\n\t{\n\t\t\"make\": \"Nissan\",\n\t\t\"model\": \"Murano\",\n\t\t\"year\": 2013,\n\t\t\"specifications\": {\n\t\t\t\"mileage\": 7106,\n\t\t\t\"trim\": \"S AWD\"\n\t\t}\n\t}\n\t```\n\t- expandNestedObjects = `false` results in: `['make', 'model', 'year', 'specifications']`\n\t- expandNestedObjects = `true` results in: `['make', 'model', 'year', 'specifications.mileage', 'specifications.trim']`\n- expandArrayObjects - `Boolean` (Default: `false`) - Should objects appearing in arrays in the provided \nobject also be expanded, such that keys appearing in those objects are extracted and \nincluded in the returned key path list?\n\t- Example:\n\t```json\n\t{\n\t\t\"make\": \"Nissan\",\n\t\t\"model\": \"GT-R\",\n\t\t\"trim\": \"NISMO\",\n\t\t\"specifications\": [\n\t\t\t{\"mileage\": 10},\n\t\t\t{\"cylinders\": 6}\n\t\t]\n\t}\n\t```\n\t- expandArrayObjects = `false` results in: `['make', 'model', 'trim', 'specifications']`\n\t- expandArrayObjects = `true` results in: `['make', 'model', 'trim', 'specifications.mileage', 'specifications.cylinders']`\n- ignoreEmptyArraysWhenExpanding - `Boolean` (Default: `false`) - Should empty array keys be ignored when expanding array objects?\n\t- Note: This only has an effect when used with `expandArrayObjects`.\n\t- Example:\n\t```json\n\t{ \n\t\t\"features\": [ {\"name\": \"A/C\" }],\n\t\t\"rebates\": []\n\t}\n\t```\n\t- ignoreEmptyArraysWhenExpanding = `false` results in: `['features.name', 'rebates']`\n\t- ignoreEmptyArraysWhenExpanding = `true` results in: `['features.name']`\n- escapeNestedDots - `Boolean` (Default: `false`) - Should `.` characters that appear in keys be escaped with a preceding `\\` character?\n\t- Example:\n\t```json\n\t{\n\t\t\"a.a\": \"1\",\n\t\t\"a.b\": {\n\t\t\t\"c\": \"2\",\n\t\t\t\"c.d\": \"3\"\n\t\t}\n\t}\n\t```\n\t- escapeNestedDots = `false` results in: `['a.a', 'a.b.c', 'a.b.c.d']`\n\t- escapeNestedDots = `true` results in: `['a\\\\.a', 'a\\\\.b.c', 'a\\\\.b.c\\\\.d']`\n- ignoreEmptyArrays - `Boolean` (Default: `false`) - Should key paths for empty arrays be ignored in the generated key list?\n\t- Example:\n\t```json\n\t{\n\t\t\"a\": {\n\t\t\t\"b\": [],\n\t\t\t\"c\": {\n\t\t\t\t\"f\": 4,\n\t\t\t\t\"e\": []\n\t\t\t}\n\t\t},\n\t\t\"b\": []\n\t}\n\t```\n\t- ignoreEmptyArrays = `false` results in `['a.b', 'a.c.f', 'a.c.e', 'b']`\n\t- ignoreEmptyArrays = `true` results in `['a.c.f']`\n\nReturns: `string[]`\n\nExample: `['make', 'model', 'specifications.odometer.miles', 'specifications.odometer.kilometers']`\n\n### deepKeysFromList\n\n`deepKeysFromList(array, options)`\n\nReturns all keys in each object in the array, even if the keys are nested \nseveral layers deep in each of the documents. These can also be used with the \n[`doc-path`](https://github.com/mrodrig/doc-path) module.\n\nOptions (optional):\n- expandNestedObjects - `Boolean` (Default: `true`) - Should nested objects appearing in the provided object also be expanded, such asthat keys appearing in those objects are extracted and included in the returned key path list?\n\t- Example:\n\t```json\n\t{\n\t\t\"make\": \"Nissan\",\n\t\t\"model\": \"Murano\",\n\t\t\"year\": 2013,\n\t\t\"specifications\": {\n\t\t\t\"mileage\": 7106,\n\t\t\t\"trim\": \"S AWD\"\n\t\t}\n\t}\n\t```\n\t- expandNestedObjects = `false` results in: `['make', 'model', 'year', 'specifications']`\n\t- expandNestedObjects = `true` results in: `['make', 'model', 'year', 'specifications.mileage', 'specifications.trim']`\n- expandArrayObjects - `Boolean` (Default: `false`) - Should objects appearing in arrays in the provided \nobject also be expanded, such that keys appearing in those objects are extracted and \nincluded in the returned key path list?\n\t- Example:\n\t```json\n\t{\n\t\t\"make\": \"Nissan\",\n\t\t\"model\": \"GT-R\",\n\t\t\"trim\": \"NISMO\",\n\t\t\"specifications\": [\n\t\t\t{\"mileage\": 10},\n\t\t\t{\"cylinders\": 6}\n\t\t]\n\t}\n\t```\n\t- expandArrayObjects = `false` results in: `['make', 'model', 'trim', 'specifications']`\n\t- expandArrayObjects = `true` results in: `['make', 'model', 'trim', 'specifications.mileage', 'specifications.cylinders']`\n- ignoreEmptyArraysWhenExpanding - `Boolean` (Default: `false`) - Should empty array keys be ignored when expanding array objects?\n\t- Note: This only has an effect when used with `expandArrayObjects`.\n\t- Example:\n\t```json\n\t[\n\t\t{ \"features\": [ {\"name\": \"A/C\" }] },\n\t\t{ \"features\": [] }\n\t] \n\t```\n\t- ignoreEmptyArraysWhenExpanding = `false` results in: `[ ['features.name', 'features'] ]`\n\t- ignoreEmptyArraysWhenExpanding = `true` results in: `[ ['features.name'] ]`\n- escapeNestedDots - `Boolean` (Default: `false`) - Should `.` characters that appear in keys be escaped with a preceding `\\` character.\n\t- Example:\n\t```json\n\t[\n\t\t{\n\t\t\t\"a.a\": \"1\",\n\t\t\t\"a.b\": {\n\t\t\t\t\"c\": \"2\",\n\t\t\t\t\"c.d\": \"3\"\n\t\t\t}\n\t\t}\n\t]\n\t```\n\t- escapeNestedDots = `false` results in: `[ ['a.a', 'a.b.c', 'a.b.c.d'] ]`\n\t- escapeNestedDots = `true` results in: `[ ['a\\\\.a', 'a\\\\.b.c', 'a\\\\.b.c\\\\.d'] ]`\n- ignoreEmptyArrays - `Boolean` (Default: `false`) - Should key paths for empty arrays be ignored in the generated key list?\n\t- Example:\n\t```json\n\t[\n\t\t{\n\t\t\t\"a\": {\n\t\t\t\t\"b\": [],\n\t\t\t\t\"c\": {\n\t\t\t\t\t\"f\": 4,\n\t\t\t\t\t\"e\": []\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"b\": []\n\t\t}\n\t]\n\t```\n\t- ignoreEmptyArrays = `false` results in `[ ['a.b', 'a.c.f', 'a.c.e', 'b'] ]`\n\t- ignoreEmptyArrays = `true` results in `[ ['a.c.f'] ]`\n\nReturns: `string[][]`\n\nExample: `[ ['make', 'model', 'specifications.odometer.miles', 'specifications.odometer.kilometers'] ]`\n\n## Examples\n\nThis module integrates really nicely with the \n[`doc-path`](https://github.com/mrodrig/doc-path) module, which allows\nthe programmatic getting and setting of key paths produced by this module.\n\nAdditionally, `doc-path@\u003e=3` works with the keys returned when the `escapeNestedDots` option is specified.\n\nHere's an example of how this works:\n\n```javascript\nconst path = require('doc-path'),\n      { deepKeys } = require('deeks');\n\nlet car = {\n\t\tmake: 'Nissan',\n\t\tmodel: 'GT-R',\n\t\ttrim: 'NISMO',\n\t\tspecifications: {\n\t\t\tmileage: 10,\n\t\t\tcylinders: '6'\n\t\t}\n\t},\n\t\n\tcarKeys = deepKeys(car);\n\nfor(let keyPath of carKeys) {\n    // Clear all values\n    path.setPath(car, keyPath, '');\n}\n```\n\n## Tests\n\n```bash\n$ npm test\n```\n\n_Note_: This requires `mocha`.\n\nTo see test coverage, please run:\n```bash\n$ npm run coverage\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrodrig%2Fdeeks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrodrig%2Fdeeks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrodrig%2Fdeeks/lists"}