{"id":27541784,"url":"https://github.com/marziply/yankee-doodle","last_synced_at":"2026-05-15T18:34:44.418Z","repository":{"id":37992402,"uuid":"237670195","full_name":"marziply/yankee-doodle","owner":"marziply","description":"Yank values from an object via a feature rich schema","archived":false,"fork":false,"pushed_at":"2023-01-07T10:42:46.000Z","size":1319,"stargazers_count":1,"open_issues_count":3,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-18T07:31:14.933Z","etag":null,"topics":["javascript","json","nested-properties","pick","schemas","yank-values","yanking-properties"],"latest_commit_sha":null,"homepage":"https://marziply.github.io/yankee-doodle","language":"JavaScript","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/marziply.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-01T19:59:55.000Z","updated_at":"2022-04-25T12:43:31.000Z","dependencies_parsed_at":"2023-02-06T23:01:30.132Z","dependency_job_id":null,"html_url":"https://github.com/marziply/yankee-doodle","commit_stats":null,"previous_names":["bakewellcake/yankee-doodle"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/marziply/yankee-doodle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marziply%2Fyankee-doodle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marziply%2Fyankee-doodle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marziply%2Fyankee-doodle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marziply%2Fyankee-doodle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marziply","download_url":"https://codeload.github.com/marziply/yankee-doodle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marziply%2Fyankee-doodle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33074872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["javascript","json","nested-properties","pick","schemas","yank-values","yanking-properties"],"created_at":"2025-04-18T23:59:38.561Z","updated_at":"2026-05-15T18:34:44.388Z","avatar_url":"https://github.com/marziply.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yankee Doodle\n\nYankee Doodle, abbreviated as Yank, is a Lodash.pick inspired JavaScript\npackage to pick object values from plain JavaScript objects. There's zero\ndependencies to worry about, so naturally this package is really small at\nonly around 9K minified. It's safe to use in both browser and Node\nenvironments.\n\n\u003e _IE11 support is currently lacking due to some regular expressions that\n\u003e aren't available in IE11 - stop using IE11!_\n\n## Installing\n\n```sh\n$ npm i -S yankee-doodle\n```\n\n## Getting Started\n\nIf you're familiar with the `pick/pickBy` methods in Lodash, then this\npackage should be easy to understand quickly. You can think of this package\nlike a superset to `pick` from Lodash, with a feature rich schema syntax\nthat allows picking properties from an object in a much more declarative way.\n\nYanking properties from objects can be done by providing the data you want\nto extract values from as the first parameter to the `yank` method, and the\nproperties you wish to extract as either an array of schemas or as a series\nof arguments.\n\nThe schemas you provide to Yank follow a similar syntax to JSON objects,\nonly with the values stripped. There are additional syntaxes for\nmanipulating which values are picked called filters.\n\nAll syntax and demo examples below use [tests/data.json](/tests/data.json)\nas the source of data for picking values from, as shown below.\n\n```json\n{\n  \"firstName\": \"John\",\n  \"lastName\": \"Doe\",\n  \"dateOfBirth\": \"1985-01-01\",\n  \"addressDetails\": {\n    \"address1\": \"10 Downing Street\",\n    \"address2\": null,\n    \"address3\": null,\n    \"city\": \"London\",\n    \"postcode\": \"SW1A 2AB\"\n  },\n  \"nested\": {\n    \"data\": {\n      \"items\": {\n        \"one\": \"one\",\n        \"two\": \"two\",\n        \"three\": \"three\"\n      }\n    }\n  }\n}\n```\n\n## Syntax\n\nExamples of schemas shown below are the strings you would provide as arguments\nto Yank, each followed by their resulting value. Each schema example is assumed\nto be the first and only schema parameter given to Yank.\n\n#### Root property access\n\n\u003csup\u003e**Schema**\u003c/sup\u003e\n\n```text\nfirstName,\nlastName\n```\n\n\u003csup\u003e**Result**\u003c/sup\u003e\n\n```json\n{\n  \"firstName\": \"John\",\n  \"lastName\": \"Doe\"\n}\n```\n\n---\n\n#### Nested properties\n\n\u003csup\u003e**Schema**\u003c/sup\u003e\n\n```text\naddressDetails: {\n  city\n}\n```\n\n\u003csup\u003e**Result**\u003c/sup\u003e\n\n```json\n{\n  \"addressDetails\": {\n    \"city\": \"London\"\n  }\n}\n```\n\n---\n\n#### Property path access\n\n\u003csup\u003e**Schema**\u003c/sup\u003e\n\n```text\naddressDetails.city,\nnested.data.items: {\n  one,\n  two\n}\n```\n\n\u003csup\u003e**Result**\u003c/sup\u003e\n\n```json\n{\n  \"city\": \"London\",\n  \"items\": {\n    \"one\": \"one\",\n    \"two\": \"two\"\n  }\n}\n```\n\n---\n\n## Filters\n\nOn each key within a schema, filters can be applied to manipulate how Yank\nhandles the value at that location. Filters are placed after the key, separated\nby a pipe (`|`), followed by parenthesis if the filter requires any arguments.\nIf no arguments are required, the parenthesis can be omitted. Multiple filters\ncan be applied simply by chaining additional filters separated by a pipe.\n\nIn addition, a macro flag can be applied to filters that support it by adding\nan exclamation point (`!`) to the end of the filter name.\n\nBelow is an example schema that makes use of filters.\n\n\u003csup\u003e**Schema**\u003c/sup\u003e\n\n```text\nfirstName | as(first_name),\nlastName | as(last_name),\ndoesNotExist | nullable,\nalsoDoesNotExist | nullable!: {\n  thisWillBeNull,\n  soWillThis\n},\ndateOfBirth | as(dob) | nullable,\nthisWontBeInTheResult\n```\n\n\u003csup\u003e**Result**\u003c/sup\u003e\n\n```json\n{\n  \"first_name\": \"John\",\n  \"last_name\": \"Doe\",\n  \"doesNotExist\": null,\n  \"alsoDoesNotExist\": {\n    \"thisWillBeNull\": null,\n    \"soWillThis\": null\n  },\n  \"dob\": \"1985-01-01\"\n}\n```\n\n#### Available filters\n\n| Name | Arguments | Macro | Description |\n|:---|:---|:---|:---|\n| as | (alias) |  | Renames the picked property |\n| nullable |  | Sets child properties to nullable | Sets property to nullable |\n| extract |  |  | Merges properties into the parent depth |\n| exec | (key, ...args) |  | Executes a method at the current depth with\u003cbr\u003eadditional arguments passed to the method |\n\n## Demo\n\nSimply spread the property names into the `yank` method and it will return\nonly those values from the given object.\n\n\u003csup\u003e**Usage**\u003c/sup\u003e\n``` javascript\nyank(data, 'firstName', 'lastName')\n```\n\n\u003csup\u003e**Result**\u003c/sup\u003e\n```json\n{\n  \"firstName\": \"John\",\n  \"lastName\": \"Doe\"\n}\n```\n\n---\n\nAlternatively, provide an array instead, or even a spread array of arrays,\nit's all the same.\n\n\u003csup\u003e**Usage**\u003c/sup\u003e\n\n``` javascript\nyank(data, ['firstName'], ['lastName'])\n```\n\n\u003csup\u003e**Result**\u003c/sup\u003e\n\n```json\n{\n  \"firstName\": \"John\",\n  \"lastName\": \"Doe\"\n}\n```\n\n---\n\nAll schemas are stripped of whitespace before parsing, so it's easy and\nconvenient to format them like you would for JSON.\n\n\u003csup\u003e**Usage**\u003c/sup\u003e\n\n``` javascript\nyank(data, `\n  nested: {\n    data: {\n      items: {\n        one,\n        two\n      }\n    }\n  }\n`)\n```\n\n\u003csup\u003e**Result**\u003c/sup\u003e\n\n```json\n{\n  \"nested\": {\n    \"data\": {\n      \"items\": {\n        \"one\": \"one\",\n        \"two\": \"two\"\n      }\n    }\n  }\n}\n```\n\n---\n\nHave a nested object? Similar to JSON syntax, use `{` and `}` to yank child\nproperties. This can be as nested as you like.\n\n\u003csup\u003e**Usage**\u003c/sup\u003e\n\n``` javascript\nyank(data, 'addressDetails: { address1, city }', 'firstName')\n```\n\n```json\n{\n  \"addressDetails\": {\n    \"address1\": \"10 Downing Street\",\n    \"city\": \"London\"\n  },\n  \"firstName\": \"John\"\n}\n```\n\n---\n\nDeeply nesting is possible as well.\n\n\u003csup\u003e**Usage**\u003c/sup\u003e\n\n``` javascript\nyank(data, `\n  nested: {\n    data: {\n      items: {\n        one,\n        two\n      }\n    }\n  }\n`)\n```\n\n```json\n{\n  \"nested\": {\n    \"data\": {\n      \"items\": {\n        \"one\": \"one\",\n        \"two\": \"two\"\n      }\n    }\n  }\n}\n```\n\nYanking properties that don't exist will result in nothing happening for\nthat particular key. The example below demonstrates that an empty object is\nreturned because neither of the given properties exist on the original data\nobject.\n\n\u003csup\u003e**Usage**\u003c/sup\u003e\n\n``` javascript\nyank(data, 'emailAddress', 'phoneNumber')\n```\n\n\u003csup\u003e**Result**\u003c/sup\u003e\n```json\n{}\n```\n\n---\n\nMixing existing properties with properties that don't exist works too. The\nones that don't exist simply get ignored.\n\n\u003csup\u003e**Usage**\u003c/sup\u003e\n\n``` javascript\nyank(data, [\n  `addressDetails: {\n    county\n  }`,\n  `addressDetails: {\n    city\n  }`,\n  'dateOfBirth'\n])\n```\n\n\u003csup\u003e**Result**\u003c/sup\u003e\n\n```json\n{\n  \"addressDetails\": {\n    \"city\": \"London\"\n  },\n  \"dateOfBirth\": \"1985-01-01\"\n}\n```\n\n---\n\n## Tests\n\n```sh\n$ npm test\n```\n\n## Acknowledgments\n\n* Heavily inspired by\n  [Lodash.pick](https://github.com/lodash/lodash/blob/master/pick.js)\n  and [supick](https://github.com/PavloAndriiesh/supick).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarziply%2Fyankee-doodle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarziply%2Fyankee-doodle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarziply%2Fyankee-doodle/lists"}