{"_id":"update-section","_rev":"304939","name":"update-section","description":"Updates a section inside a file with newer content while removing the old content.","dist-tags":{"latest":"0.3.3"},"maintainers":[{"name":"thlorenz","email":"thlorenz@gmx.de"}],"time":{"modified":"2021-06-03T19:28:27.000Z","created":"2013-12-11T20:48:22.419Z","0.3.3":"2014-03-07T18:17:12.171Z","0.3.2":"2014-03-07T18:12:04.525Z","0.3.1":"2014-03-07T05:35:47.717Z","0.3.0":"2014-03-07T05:25:43.667Z","0.2.0":"2014-03-07T04:37:46.236Z","0.1.2":"2014-01-02T00:56:06.152Z","0.1.1":"2013-12-11T21:26:58.285Z","0.1.0":"2013-12-11T20:48:22.419Z"},"users":{},"author":{"name":"Thorsten Lorenz","email":"thlorenz@gmx.de","url":"http://thlorenz.com"},"repository":{"type":"git","url":"git://github.com/thlorenz/update-section.git"},"versions":{"0.3.3":{"name":"update-section","version":"0.3.3","description":"Updates a section inside a file with newer content while removing the old content.","main":"update-section.js","scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"repository":{"type":"git","url":"git://github.com/thlorenz/update-section.git"},"homepage":"https://github.com/thlorenz/update-section","dependencies":{},"devDependencies":{"tape":"~1.0.4"},"keywords":["update","replace","section","regex","readme","text"],"author":{"name":"Thorsten Lorenz","email":"thlorenz@gmx.de","url":"http://thlorenz.com"},"license":{"type":"MIT","url":"https://github.com/thlorenz/update-section/blob/master/LICENSE"},"engine":{"node":">=0.6"},"testling":{"files":"test/*.js","browsers":["ie/8..latest","firefox/22..latest","firefox/nightly","chrome/27..latest","chrome/canary","opera/12..latest","opera/next","safari/5.1..latest","ipad/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]},"bugs":{"url":"https://github.com/thlorenz/update-section/issues"},"_id":"update-section@0.3.3","dist":{"shasum":"458f17820d37820dc60e20b86d94391b00123158","size":4077,"noattachment":false,"key":"/update-section/-/update-section-0.3.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/update-section/download/update-section-0.3.3.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"thlorenz","email":"thlorenz@gmx.de"},"maintainers":[{"name":"thlorenz","email":"thlorenz@gmx.de"}],"directories":{},"publish_time":1394216232171,"_cnpm_publish_time":1394216232171,"_hasShrinkwrap":false},"0.3.2":{"name":"update-section","version":"0.3.2","description":"Updates a section inside a file with newer content while removing the old content.","main":"update-section.js","scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"repository":{"type":"git","url":"git://github.com/thlorenz/update-section.git"},"homepage":"https://github.com/thlorenz/update-section","dependencies":{},"devDependencies":{"tape":"~1.0.4"},"keywords":["update","replace","section","regex","readme","text"],"author":{"name":"Thorsten Lorenz","email":"thlorenz@gmx.de","url":"http://thlorenz.com"},"license":{"type":"MIT","url":"https://github.com/thlorenz/update-section/blob/master/LICENSE"},"engine":{"node":">=0.6"},"testling":{"files":"test/*.js","browsers":["ie/8..latest","firefox/22..latest","firefox/nightly","chrome/27..latest","chrome/canary","opera/12..latest","opera/next","safari/5.1..latest","ipad/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]},"bugs":{"url":"https://github.com/thlorenz/update-section/issues"},"_id":"update-section@0.3.2","dist":{"shasum":"46745d810882cfc775f963879922a5416a32615c","size":4076,"noattachment":false,"key":"/update-section/-/update-section-0.3.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/update-section/download/update-section-0.3.2.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"thlorenz","email":"thlorenz@gmx.de"},"maintainers":[{"name":"thlorenz","email":"thlorenz@gmx.de"}],"directories":{},"publish_time":1394215924525,"_cnpm_publish_time":1394215924525,"_hasShrinkwrap":false},"0.3.1":{"name":"update-section","version":"0.3.1","description":"Updates a section inside a file with newer content while removing the old content.","main":"update-section.js","scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"repository":{"type":"git","url":"git://github.com/thlorenz/update-section.git"},"homepage":"https://github.com/thlorenz/update-section","dependencies":{},"devDependencies":{"tape":"~1.0.4"},"keywords":["update","replace","section","regex","readme","text"],"author":{"name":"Thorsten Lorenz","email":"thlorenz@gmx.de","url":"http://thlorenz.com"},"license":{"type":"MIT","url":"https://github.com/thlorenz/update-section/blob/master/LICENSE"},"engine":{"node":">=0.6"},"testling":{"files":"test/*.js","browsers":["ie/8..latest","firefox/22..latest","firefox/nightly","chrome/27..latest","chrome/canary","opera/12..latest","opera/next","safari/5.1..latest","ipad/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]},"bugs":{"url":"https://github.com/thlorenz/update-section/issues"},"_id":"update-section@0.3.1","dist":{"shasum":"a5ef12d402389be85a1e5e8fc9e1c4cd2045cb60","size":4069,"noattachment":false,"key":"/update-section/-/update-section-0.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/update-section/download/update-section-0.3.1.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"thlorenz","email":"thlorenz@gmx.de"},"maintainers":[{"name":"thlorenz","email":"thlorenz@gmx.de"}],"directories":{},"publish_time":1394170547717,"_cnpm_publish_time":1394170547717,"_hasShrinkwrap":false},"0.3.0":{"name":"update-section","version":"0.3.0","description":"Updates a section inside a file with newer content while removing the old content.","main":"update-section.js","scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"repository":{"type":"git","url":"git://github.com/thlorenz/update-section.git"},"homepage":"https://github.com/thlorenz/update-section","dependencies":{},"devDependencies":{"tape":"~1.0.4"},"keywords":["update","replace","section","regex","readme","text"],"author":{"name":"Thorsten Lorenz","email":"thlorenz@gmx.de","url":"http://thlorenz.com"},"license":{"type":"MIT","url":"https://github.com/thlorenz/update-section/blob/master/LICENSE"},"engine":{"node":">=0.6"},"testling":{"files":"test/*.js","browsers":["ie/8..latest","firefox/22..latest","firefox/nightly","chrome/27..latest","chrome/canary","opera/12..latest","opera/next","safari/5.1..latest","ipad/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]},"bugs":{"url":"https://github.com/thlorenz/update-section/issues"},"_id":"update-section@0.3.0","dist":{"shasum":"e2b843611239a5739805d8d92467fd91702b92b1","size":4074,"noattachment":false,"key":"/update-section/-/update-section-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/update-section/download/update-section-0.3.0.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"thlorenz","email":"thlorenz@gmx.de"},"maintainers":[{"name":"thlorenz","email":"thlorenz@gmx.de"}],"directories":{},"publish_time":1394169943667,"_cnpm_publish_time":1394169943667,"_hasShrinkwrap":false},"0.2.0":{"name":"update-section","version":"0.2.0","description":"Updates a section inside a file with newer content while removing the old content.","main":"update-section.js","scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"repository":{"type":"git","url":"git://github.com/thlorenz/update-section.git"},"homepage":"https://github.com/thlorenz/update-section","dependencies":{},"devDependencies":{"tape":"~1.0.4"},"keywords":["update","replace","section","regex","readme","text"],"author":{"name":"Thorsten Lorenz","email":"thlorenz@gmx.de","url":"http://thlorenz.com"},"license":{"type":"MIT","url":"https://github.com/thlorenz/update-section/blob/master/LICENSE"},"engine":{"node":">=0.6"},"testling":{"files":"test/*.js","browsers":["ie/8..latest","firefox/22..latest","firefox/nightly","chrome/27..latest","chrome/canary","opera/12..latest","opera/next","safari/5.1..latest","ipad/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]},"bugs":{"url":"https://github.com/thlorenz/update-section/issues"},"_id":"update-section@0.2.0","dist":{"shasum":"96eba8b9a28b12605206d136b3d85d736d0f966a","size":3955,"noattachment":false,"key":"/update-section/-/update-section-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/update-section/download/update-section-0.2.0.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"thlorenz","email":"thlorenz@gmx.de"},"maintainers":[{"name":"thlorenz","email":"thlorenz@gmx.de"}],"directories":{},"publish_time":1394167066236,"_cnpm_publish_time":1394167066236,"_hasShrinkwrap":false},"0.1.2":{"name":"update-section","version":"0.1.2","description":"Updates a section inside a file with newer content while removing the old content.","main":"update-section.js","scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"repository":{"type":"git","url":"git://github.com/thlorenz/update-section.git"},"homepage":"https://github.com/thlorenz/update-section","dependencies":{},"devDependencies":{"tape":"~1.0.4"},"keywords":["update","replace","section","regex","readme","text"],"author":{"name":"Thorsten Lorenz","email":"thlorenz@gmx.de","url":"http://thlorenz.com"},"license":{"type":"MIT","url":"https://github.com/thlorenz/update-section/blob/master/LICENSE"},"engine":{"node":">=0.6"},"testling":{"files":"test/*.js","browsers":["ie/8..latest","firefox/22..latest","firefox/nightly","chrome/27..latest","chrome/canary","opera/12..latest","opera/next","safari/5.1..latest","ipad/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]},"readmeFilename":"README.md","bugs":{"url":"https://github.com/thlorenz/update-section/issues"},"_id":"update-section@0.1.2","dist":{"shasum":"6e41245b25025501d3393468e63e04be29bdb7ef","size":3042,"noattachment":false,"key":"/update-section/-/update-section-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/update-section/download/update-section-0.1.2.tgz"},"_from":".","_npmVersion":"1.3.22","_npmUser":{"name":"thlorenz","email":"thlorenz@gmx.de"},"maintainers":[{"name":"thlorenz","email":"thlorenz@gmx.de"}],"directories":{},"publish_time":1388624166152,"_cnpm_publish_time":1388624166152,"_hasShrinkwrap":false},"0.1.1":{"name":"update-section","version":"0.1.1","description":"Updates a section inside a file with newer content while removing the old content.","main":"update-section.js","scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"repository":{"type":"git","url":"git://github.com/thlorenz/update-section.git"},"homepage":"https://github.com/thlorenz/update-section","dependencies":{},"devDependencies":{"tape":"~1.0.4"},"keywords":["update","replace","section","regex","readme","text"],"author":{"name":"Thorsten Lorenz","email":"thlorenz@gmx.de","url":"http://thlorenz.com"},"license":{"type":"MIT","url":"https://github.com/thlorenz/update-section/blob/master/LICENSE"},"engine":{"node":">=0.6"},"testling":{"files":"test/*.js","browsers":["ie/8..latest","firefox/17..latest","firefox/nightly","chrome/22..latest","chrome/canary","opera/12..latest","opera/next","safari/5.1..latest","ipad/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]},"readmeFilename":"README.md","bugs":{"url":"https://github.com/thlorenz/update-section/issues"},"_id":"update-section@0.1.1","dist":{"shasum":"842773e5f635912893bb0488e3301daddf36f8af","size":3061,"noattachment":false,"key":"/update-section/-/update-section-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/update-section/download/update-section-0.1.1.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"thlorenz","email":"thlorenz@gmx.de"},"maintainers":[{"name":"thlorenz","email":"thlorenz@gmx.de"}],"directories":{},"publish_time":1386797218285,"_cnpm_publish_time":1386797218285,"_hasShrinkwrap":false},"0.1.0":{"name":"update-section","version":"0.1.0","description":"Updates a section inside a file with newer content while removing the old content.","main":"update-section.js","scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"repository":{"type":"git","url":"git://github.com/thlorenz/update-section.git"},"homepage":"https://github.com/thlorenz/update-section","dependencies":{},"devDependencies":{"tape":"~1.0.4"},"keywords":["update","replace","section","regex","readme","text"],"author":{"name":"Thorsten Lorenz","email":"thlorenz@gmx.de","url":"http://thlorenz.com"},"license":{"type":"MIT","url":"https://github.com/thlorenz/update-section/blob/master/LICENSE"},"engine":{"node":">=0.6"},"testling":{"files":"test/*.js","browsers":["ie/8..latest","firefox/17..latest","firefox/nightly","chrome/22..latest","chrome/canary","opera/12..latest","opera/next","safari/5.1..latest","ipad/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]},"readmeFilename":"README.md","bugs":{"url":"https://github.com/thlorenz/update-section/issues"},"_id":"update-section@0.1.0","dist":{"shasum":"661ef64eae39e4b9e2d2607d4daba1403946b0c9","size":3040,"noattachment":false,"key":"/update-section/-/update-section-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/update-section/download/update-section-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"thlorenz","email":"thlorenz@gmx.de"},"maintainers":[{"name":"thlorenz","email":"thlorenz@gmx.de"}],"directories":{},"publish_time":1386794902419,"_cnpm_publish_time":1386794902419,"_hasShrinkwrap":false}},"readme":"# update-section [![build status](https://secure.travis-ci.org/thlorenz/update-section.png)](http://travis-ci.org/thlorenz/update-section)\n\n[![testling badge](https://ci.testling.com/thlorenz/update-section.png)](https://ci.testling.com/thlorenz/update-section)\n\nUpdates a section inside a file with newer content while removing the old content.\n\n```js\nvar updateSection = require('update-section');\n\nvar original = [\n    '# Some Project'\n  , ''\n  , 'Does a bunch of things'\n  , ''\n  , 'START -- GENERATED GOODNESS'\n  , 'this was painstakingly generated'\n  , 'as was this'\n  , 'END -- GENERATED GOODNESS' , ''\n  , ''\n  , '## The End'\n  , ''\n  , 'Til next time'\n].join('\\n');\n\nvar update = [\n    'START -- GENERATED GOODNESS'\n  , 'this was painstakingly re-generated'\n  , 'and we added another line'\n  , 'here'\n  , 'END -- GENERATED GOODNESS'\n].join('\\n');\n\nfunction matchesStart(line) {\n  return (/START -- GENERATED GOODNESS/).test(line);  \n}\n\nfunction matchesEnd(line) {\n  return (/END -- GENERATED GOODNESS/).test(line);  \n}\n\nvar updated = updateSection(original, update, matchesStart, matchesEnd);\nconsole.log(updated);\n```\n\n#### Output\n```\n# Some Project\n\nDoes a bunch of things\n\nSTART -- GENERATED GOODNESS\nthis was painstakingly re-generated\nand we added another line\nhere\nEND -- GENERATED GOODNESS\n\n## The End\n\nTil next time\n```\n\n## Installation\n\n    npm install update-section\n\n## API\n\n### updateSection(content, section, matchesStart, matchesEnd)\n\n```\n/**\n * Updates the content with the given section. \n *\n * If previous section is found it is replaced.\n * Otherwise the section is appended to the end of the content.\n *\n * @name updateSection\n * @function\n * @param {String} content that may or may not include a previously added section\n * @param {String} section the section to update\n * @param {Function} matchesStart when called with a line needs to return true iff it is the section start line\n * @param {Function} matchesEnd when called with a line needs to return true iff it is the section end line\n * @return {String} content with updated section\n */\n```\n\n## License\n\nMIT\n\n\n<!-- START docme generated API please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN docme TO UPDATE -->\n\n<div>\n<div class=\"jsdoc-githubify\">\n<section>\n<article>\n<div class=\"container-overview\">\n<dl class=\"details\">\n</dl>\n</div>\n<dl>\n<dt>\n<h4 class=\"name\" id=\"updateSection\"><span class=\"type-signature\"></span>updateSection<span class=\"signature\">(content, section, matchesStart, matchesEnd, top)</span><span class=\"type-signature\"> &rarr; {String}</span></h4>\n</dt>\n<dd>\n<div class=\"description\">\n<p>Updates the content with the given section. </p>\n<p>If previous section is found it is replaced.\nOtherwise the section is appended to the end of the content.</p>\n</div>\n<h5>Parameters:</h5>\n<table class=\"params\">\n<thead>\n<tr>\n<th>Name</th>\n<th>Type</th>\n<th class=\"last\">Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td class=\"name\"><code>content</code></td>\n<td class=\"type\">\n<span class=\"param-type\">String</span>\n</td>\n<td class=\"description last\"><p>that may or may not include a previously added section</p></td>\n</tr>\n<tr>\n<td class=\"name\"><code>section</code></td>\n<td class=\"type\">\n<span class=\"param-type\">String</span>\n</td>\n<td class=\"description last\"><p>the section to update</p></td>\n</tr>\n<tr>\n<td class=\"name\"><code>matchesStart</code></td>\n<td class=\"type\">\n<span class=\"param-type\">function</span>\n</td>\n<td class=\"description last\"><p>when called with a line needs to return true iff it is the section start line</p></td>\n</tr>\n<tr>\n<td class=\"name\"><code>matchesEnd</code></td>\n<td class=\"type\">\n<span class=\"param-type\">function</span>\n</td>\n<td class=\"description last\"><p>when called with a line needs to return true iff it is the section end line</p></td>\n</tr>\n<tr>\n<td class=\"name\"><code>top</code></td>\n<td class=\"type\">\n<span class=\"param-type\">boolean</span>\n</td>\n<td class=\"description last\"><p>forces the section to be added at the top of the content if a replacement couldn't be made</p></td>\n</tr>\n</tbody>\n</table>\n<dl class=\"details\">\n<dt class=\"tag-source\">Source:</dt>\n<dd class=\"tag-source\"><ul class=\"dummy\">\n<li>\n<a href=\"https://github.com/thlorenz/update-section/blob/master/update-section.js\">update-section.js</a>\n<span>, </span>\n<a href=\"https://github.com/thlorenz/update-section/blob/master/update-section.js#L44\">lineno 44</a>\n</li>\n</ul></dd>\n</dl>\n<h5>Returns:</h5>\n<div class=\"param-desc\">\n<p>content with updated section</p>\n</div>\n<dl>\n<dt>\nType\n</dt>\n<dd>\n<span class=\"param-type\">String</span>\n</dd>\n</dl>\n</dd>\n<dt>\n<h4 class=\"name\" id=\"updateSection::parse\"><span class=\"type-signature\"></span>updateSection::parse<span class=\"signature\">(lines, matchesStart, matchesEnd)</span><span class=\"type-signature\"> &rarr; {object}</span></h4>\n</dt>\n<dd>\n<div class=\"description\">\n<p>Finds the start and end lines that match the given criteria.\nUsed by update-section itself.</p>\n<p>Use it if you need to get information about where the matching content is located.</p>\n</div>\n<h5>Parameters:</h5>\n<table class=\"params\">\n<thead>\n<tr>\n<th>Name</th>\n<th>Type</th>\n<th class=\"last\">Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td class=\"name\"><code>lines</code></td>\n<td class=\"type\">\n<span class=\"param-type\">Array.&lt;string></span>\n</td>\n<td class=\"description last\"><p>the lines in which to look for matches</p></td>\n</tr>\n<tr>\n<td class=\"name\"><code>matchesStart</code></td>\n<td class=\"type\">\n<span class=\"param-type\">function</span>\n</td>\n<td class=\"description last\"><p>when called with a line needs to return true iff it is the section start line</p></td>\n</tr>\n<tr>\n<td class=\"name\"><code>matchesEnd</code></td>\n<td class=\"type\">\n<span class=\"param-type\">function</span>\n</td>\n<td class=\"description last\"><p>when called with a line needs to return true iff it is the section end line</p></td>\n</tr>\n</tbody>\n</table>\n<dl class=\"details\">\n<dt class=\"tag-source\">Source:</dt>\n<dd class=\"tag-source\"><ul class=\"dummy\">\n<li>\n<a href=\"https://github.com/thlorenz/update-section/blob/master/update-section.js\">update-section.js</a>\n<span>, </span>\n<a href=\"https://github.com/thlorenz/update-section/blob/master/update-section.js#L3\">lineno 3</a>\n</li>\n</ul></dd>\n</dl>\n<h5>Returns:</h5>\n<div class=\"param-desc\">\n<p>with the following properties: hasStart, hasEnd, startIdx, endIdx</p>\n</div>\n<dl>\n<dt>\nType\n</dt>\n<dd>\n<span class=\"param-type\">object</span>\n</dd>\n</dl>\n</dd>\n</dl>\n</article>\n</section>\n</div>\n\n*generated with [docme](https://github.com/thlorenz/docme)*\n</div>\n<!-- END docme generated API please keep comment here to allow auto update -->","_attachments":{},"homepage":"https://github.com/thlorenz/update-section","bugs":{"url":"https://github.com/thlorenz/update-section/issues"},"license":{"type":"MIT","url":"https://github.com/thlorenz/update-section/blob/master/LICENSE"}}