{"id":15792783,"url":"https://github.com/nfour/transposer","last_synced_at":"2025-03-31T18:51:36.277Z","repository":{"id":34078419,"uuid":"37888655","full_name":"nfour/transposer","owner":"nfour","description":"Variable transposition from dataKeys","archived":false,"fork":false,"pushed_at":"2016-04-23T07:06:35.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T17:06:43.703Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","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/nfour.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-06-23T00:49:04.000Z","updated_at":"2016-04-23T06:47:39.000Z","dependencies_parsed_at":"2022-07-18T01:10:42.690Z","dependency_job_id":null,"html_url":"https://github.com/nfour/transposer","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/nfour%2Ftransposer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfour%2Ftransposer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfour%2Ftransposer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nfour%2Ftransposer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nfour","download_url":"https://codeload.github.com/nfour/transposer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246523897,"owners_count":20791444,"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-04T23:04:17.217Z","updated_at":"2025-03-31T18:51:36.255Z","avatar_url":"https://github.com/nfour.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trasposer\nA small and fast *\"dataKey\"* transposer.\n\nThis module turns `here.is[2].some[\"!data!\"]` into\n```js\n{\n    here: {\n        is: [\n            , , { some: { \"!data!\": 'a value' } }\n        ]\n    }\n}\n```\n\nThe dataKey syntax is just javascript.\nYou can even start the dataKey with an array index to create an array.\n```js\nnew Transposer().transpose( '[1].test', 'test' ) // returns [ , { test: 'test' } ]\n```\n\nOne usecase of many:\n```html\n\u003cinput name=\"some.data[0].here\" value=\"1\" /\u003e\n```\n\n#### Install\n`npm install transposer`\n\n#### class Transposer( ?data? )\n```js\nTransposer = require('transposer')\ntransposer = new Transposer({ some: { data: 1 } })\n\ntransposer.get('some.data') // returns 1\ntransposer.set('some.data.here', 2)\ntransposer.get('some.data.here') // returns 2\ntransposer.data.some.data.here // returns 2\n```\n\nSee `./Transposer.js` for parameter information.\n\n#### .transpose( dataKey, value )\nTurns `data.key[1].c` into its represented data structure.\nSets the last key in the string to a value.\n\nReturns null on an invalid dataKey.\n\n```js\nnew Transposer().transpose('some.data', 100) // returns { some: { data: 100 } }\n\n// or\n\n{ transpose } = require('transposer').prototype\ntranspose('some.data', 100) // returns { some: { data: 100 } }\n```\n\n#### .transposeAll( object )\nTransposes all properties of `object`, modifying `object`.\nAny dataKey is deleted from the object in place of the transposed parent key.\n\n```js\ndata = {\n    'name[0]': 'Jim'\n    'name[1]': 'Bob'\n    type: 'person'\n}\n\ntransposer.transposeAll(data)\n\ndata // returns { name: [ 'Jim', 'Bob' ], type: 'person' }\n```\n\n#### .set( dataKey or transposedData, value)\nSets a value in `this.data`.\n\n```js\n// Both do the same thing\ntransposer.set('some.data', 1)\ntransposer.set({ some: { data: 1} })\ntransposer.data // returns { some: { data: 1 } }\n```\n\n#### .get( dataKey or transposedData )\nFinds a value in `this.data`.\n\n```js\ntransposer = new Transposer({ some: { data: 500 } })\n// Both yield the same thing (The value is ignored)\ntransposer.get('some.data') // returns 500\ntransposer.get({ some: { data: null } })// returns 500\n```\n\n#### .merge( obj1, obj2, depth = 16, overwrite = false )\nMerges obj2 into obj1, optionally overwriting properties.\nTries to always maintain an object's reference in obj1 unless `overwritten` is `true`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfour%2Ftransposer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnfour%2Ftransposer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnfour%2Ftransposer/lists"}