{"id":21954173,"url":"https://github.com/cssobj/cssobj-plugin-replace","last_synced_at":"2026-05-18T19:06:59.818Z","repository":{"id":57210968,"uuid":"69632823","full_name":"cssobj/cssobj-plugin-replace","owner":"cssobj","description":"Replace cssobj object key/value pair with new value(Object, Array, Function etc.)","archived":false,"fork":false,"pushed_at":"2016-10-19T06:47:09.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-19T20:06:18.524Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/cssobj.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":"2016-09-30T04:09:05.000Z","updated_at":"2016-09-30T15:28:00.000Z","dependencies_parsed_at":"2022-08-29T20:13:30.374Z","dependency_job_id":null,"html_url":"https://github.com/cssobj/cssobj-plugin-replace","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssobj%2Fcssobj-plugin-replace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssobj%2Fcssobj-plugin-replace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssobj%2Fcssobj-plugin-replace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cssobj%2Fcssobj-plugin-replace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cssobj","download_url":"https://codeload.github.com/cssobj/cssobj-plugin-replace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245001913,"owners_count":20545335,"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-11-29T07:16:54.298Z","updated_at":"2025-10-04T23:09:53.472Z","avatar_url":"https://github.com/cssobj.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cssobj-plugin-replace\n\n[![Join the chat at https://gitter.im/css-in-js/cssobj](https://badges.gitter.im/css-in-js/cssobj.svg)](https://gitter.im/css-in-js/cssobj) [![Build Status](https://travis-ci.org/cssobj/cssobj-plugin-replace.svg?branch=master)](https://travis-ci.org/cssobj/cssobj-plugin-replace)\n\n[cssobj](https://github.com/cssobj/cssobj) plugin to replace object key/value pair with new value (Object, Array, Function etc.)\n\n## Install\n\n- npm\n\n```shell\nnpm i cssobj-plugin-replace\n```\n\nThen\n\n```javascript\nvar cssobj = require('cssobj')\nvar cssobj_plugin_replace = require('cssobj-plugin-replace')\n\ncssobj(\n  { p: {color: 'red'} },\n  {\n    plugins: [\n      cssobj_plugin_replace({\n        map:[\n          // replace red with blue\n          ['color', 'red', 'blue']\n        ]\n      })\n    ]\n  }\n)\n\n// result:\np { color: blue; }\n```\n\n## Quick Start\n\n### **Replace simple value:**\n\nReplace color `red` with `blue`\n\n```javascript\ncssobj_plugin_replace({\n  map:[\n    ['color', 'red', 'blue']\n  ]\n})\n\n// { p:{color:'red'} } =\u003e p {color: blue;}\n```\n\n### **Replace value with array:**\n\n```javascript\ncssobj_plugin_replace({\n  map:[\n    ['font', '123', [1, 2, 3]]\n  ]\n})\n\n// { p:{font:123} } =\u003e p { font:1; font:2; font:3; }\n```\n\n### **Replace value with object:**\n\n```javascript\ncssobj_plugin_replace({\n  map:[\n    ['font', 'heading', {fontFamily: 'Arial', fontSize: '24px', fontWeight: 'bold'}]\n  ]\n})\n\n// { p:{font:'heading'} } =\u003e p { font-family: Arial; font-size: 24px; font-weight: bold; }\n```\n\n### **Replace value with array of object:**\n\n```javascript\ncssobj_plugin_replace({\n  map:[\n    ['display', 'flex', [{display:'-webkit-flex'}, {display:'flex'}]]\n  ]\n})\n\n// { p:{display:'flex'} } =\u003e p { display: -webkit-flex; display: flex; }\n```\n\n### **Replace any key/value:**\n\nUse **null** as placeholder for any key/value matched.\n\n**null as value to match any value**\n\n```javascript\ncssobj_plugin_replace({\n  map:[\n    ['display', null, [{display:'-webkit-flex'}, {display:'flex'}]]\n  ]\n})\n\n// { p:{display:1} } =\u003e p { display: -webkit-flex; display: flex; }\n```\n\n**null as key to match any key**\n```javascript\ncssobj_plugin_replace({\n  map:[\n    [null, 'red', [{display:'-webkit-flex'}, {display:'flex'}]]\n  ]\n})\n\n// { p:{color:'red'} } =\u003e p { display: -webkit-flex; display: flex; }\n```\n\n### **Replace with function**\n\n**newValue** can be function to dynamic calc the replacement.\n\n```javascript\ncssobj_plugin_replace({\n  map:[\n    [null, null, function(key, value){return value\u003e0 ? {[key]: value+'px'} : {[key]:value} }]\n  ]\n})\n\n// { p:{padding:1, margin:0} } =\u003e p { padding: 1px; margin:0; }\n```\n\n## Requirement\n\n**cssobj version \u003e= 0.5.2**\n\n## License\n\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcssobj%2Fcssobj-plugin-replace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcssobj%2Fcssobj-plugin-replace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcssobj%2Fcssobj-plugin-replace/lists"}