![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A high level multiline string manipulation library.
Using editer, you can:
npm install --save editer
Here are some examples of what editer can do.
Insert a new line after a certain line number.
var editer = require('editer');
var target = 'line 1\nline 3';
var result = editer.insert('line 2', target, {after: {line: 1}, asNewLine: true});
console.log(result);
// => 'line 1\nline 2\nline 3';
Insert a string after the second occurrence of regex.
import create from './create';
import generate from './generate';
export {
create
generate
};
var fs = require('fs');
var editer = require('editer');
var target = fs.readFileSync('./target');
var result = editer.insert("import modify from './modify'", target, {
after: {
regex: /import .*$/,
occurrence: 2,
},
asNewLine: true
});
console.log(result);
// import create from './create';
// import generate from './generate';
// import modify from './modify';
//
// export {
// create
// generate
// };
Inserts string
to target
at the position specified by options
and returns
the modified target
. If options
fails to find the desired position, returns
undefined
.
string
String
target
String
string
options
Object
string
is to be inserted to
target
and how it should be inserted (e.g. as a new line or a regular line).At top level, it can have the following keys:
before
after
or
asNewLine
An object with either before
or after
is a 'condition'. A condition cannot
have both before
and after
. They take as value an object with following
possible key-value pairs.
line
Number
regex
RegExp
occurrence
if providing this option. See below. All regex should have global flag, as
Editer uses lcoater internally.occurrence
Number
target
is to be modified. If not
provided, target
is modified at the first occurrence of the regex
.last
Boolean
target
at last occurrence of the regex.Example
var target = "I love you\nHoney Bunny.";
var options = {before: {regex: /[a-zA-z]{5}/g, occurrence: 2}};
var result = editer.insert("Nooby ", target, options);
console.log(result);
// => "I love you\nHoney Nooby Bunny."
var target = "Whoa, whoa, whoa, whoa... stop right there.";
var options = {before: {regex: /whoa/ig, last: true}};
var result = editer.insert("my god, ", target, options);
console.log(result);
// => "Whoa, whoa, whoa, my god, whoa... stop right there."
or
is an array of conditions. Editer attempts to use the conditions
sequentially from the first to the last. If a condition matches, Editer ignores
the rest of the conditions.
Example
var target = "Whoa, whoa, whoa, whoa... stop right there.";
var options = {or: [
{before: {regex: /unicorn/ig, last: true}},
{after: {regex: /whoa,\s/ig, occurrence: 3}},
{after: {regex: /stop/i}}
]};
var result = editer.insert("hey, ", target, options);
console.log(result);
// => "Whoa, whoa, whoa, hey, whoa... stop right there."
Boolean
false
string
as a new line to the target
.Example
var target = "It's Zed's.\nWho's Zed?";
var options = {before: {regex: /Zed.*\n/g}, asNewLine: true};
var result = editer.insert("...", target, options);
console.log(result);
// => "It's \n...\nZed's.\nWho's Zed?"
Removes string
from the target
at the position specified by options
.
string
String
target
String
string
options
Object
string
is to be removed from
target
.At top level, it can have the following keys:
before
after
or
multi
onSameLine
All before
, after
, and or
options are similar to those of insert
API.
The only difference is that here they support only regex, not line number.
Boolean
false
string
in the section of the target
scoped
by the condition, and other options such as onSameLine
.Boolean
false
MIT
FAQs
A high level multiline string manipulation library
The npm package editer receives a total of 23 weekly downloads. As such, editer popularity was classified as not popular.
We found that editer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.