Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
poliparser
Advanced tools
Readme
Poliparse is used to extract and parse data from strings, files, urls and many other objects in a simple and fast way.
The Default modules allows you to parse:
You can use the default modules or easily add your custom one ( see all the modules on the Examples page ).
npm install --save poliparser
Import and Instantiate Poliparser
const Poliparser = require('poliparser');
let p = new Poliparser();
set a parser template,
In this example is used the module between
from str
library.
p.setParser({
m: 'str_between',
from: '<title>',
to: '</title>'
});
let data = `<title>hello</title>
<div class=".container">
<a href="link1.html">link1</a>
</div>`;
let output = p.parse(data);
console.log(output);
output
hello
ps. The fastest way is to pass it in the declaration like this
let p = new Poliparser({
m: 'between',
from: '<title>',
to: '</title>'
});
See Here for complete modules documentation and Here for real world examples.
You can use setModule()
and requireModule()
to add custom modules.
let p = new Poliparser();
p.setModule('my_parse_module', (data, block) => {
return data.map(x => x * block.value);
});
p.setParser({
m: 'my_parse_module',
value: 3
});
let out = p.parse([1,2,3]);
console.log(out);
same as
let p = new Poliparser();
p.requireModule('my_parse_module', 'myModule.js');
p.setParser({
m: 'my_parse_module',
value: 3
});
let out = p.parse([1,2,3]);
console.log(out);
//myModule.js
module.exports = (data, block) => {
return data.map(x => x * block.value);
};
output
[ 3, 6, 9 ]
You can add a new library with the setLibrary or requireLibrary method.
let p = new Poliparser();
p.setLibrary('myLib', {
mul: (data, block) => {
return data * block.value;
},
sum: (data, block) => {
return data + block.value;
}
});
p.setParser([{
m: 'myLib_mul',
value: 3
},{
m: 'myLib_sum',
value: 2
}]);
let out = p.parse(10);
console.log(out);
same as
let p = new Poliparser();
p.requireLibrary('myLib', 'myLib.js');
p.setParser([{
m: 'myLib_mul',
value: 3
},{
m: 'myLib_sum',
value: 2
]);
let out = p.parse(10);
console.log(out);
//myLib.js
module.exports = {
mul: (data, block) => {
return data * block.value;
},
sum: (data, block) => {
return data + block.value;
}
}
output
32
FAQs
The only parser you need
The npm package poliparser receives a total of 1 weekly downloads. As such, poliparser popularity was classified as not popular.
We found that poliparser 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.