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.
html-attrs-sorter-promisified
Advanced tools
Readme
Promise-based API to sort html attributes.
$ npm install --save-dev html-attrs-sorter-promisified
First, things first:
var sorter = require('html-attrs-sorter-promisified');
Single input:
var htmlString = '<button id="1" disabled class="btn btn-primary" type="button">Search</button>';
sorter.attributesSorting(htmlString).then(result => console.log(result[0]));
// Outputs:
// '<button class="btn btn-primary" id="1" type="button" disabled>Search</button>'
Two inputs:
var htmlString = '<button id="1" disabled class="btn btn-primary" type="button">Search</button>';
var htmlString2 = '<button id="1" type="button" disabled class="btn btn-primary">Search</button>';
sorter.attributesSorting(htmlString, htmlString2).then(result => {
console.log(result[0]);
console.log(result[1]);
});
// Outputs:
// '<button class="btn btn-primary" id="1" type="button" disabled>Search</button>'
// '<button class="btn btn-primary" id="1" type="button" disabled>Search</button>'
N
inputs:
var htmlString = '<button id="1" disabled class="btn btn-primary" type="button">Search</button>';
var htmlString2 = '<button id="1" type="button" disabled class="btn btn-primary">Search</button>';
var htmlString3 = '<button id="1" type="button" class="btn btn-primary" disabled>Search</button>';
sorter.attributesSorting(htmlString, htmlString2, htmlString3).then(result => {
for (var prop in result) {
console.log(result[prop]);
}
});
// Outputs:
// '<button class="btn btn-primary" id="1" type="button" disabled>Search</button>'
// '<button class="btn btn-primary" id="1" type="button" disabled>Search</button>'
// '<button class="btn btn-primary" id="1" type="button" disabled>Search</button>'
Config order:
Since this module uses posthtml-attrs-sorter
under to hood, it inherits its default config object:
{
"order": [
"class", "id", "name",
"data-.+", "ng-.+", "src",
"for", "type", "href",
"values", "title", "alt",
"role", "aria-.+",
"$unknown$"
]
}
It's very simple to override the order
configuration, though. Check the following example:
// Gives "id" and "type" a higher priority
sorter.updateDefaultAttrsSorterOptions({
"order": [
"id", "type", "class", "name",
"data-.+", "ng-.+", "src",
"for", "href",
"values", "title", "alt",
"role", "aria-.+",
"$unknown$"
]
});
var htmlString = '<button id="1" disabled class="btn btn-primary" type="button">Search</button>';
sorter.attributesSorting(htmlString).then(result => console.log(result[0]));
// Outputs:
// '<button id="1" type="button" class="btn btn-primary" disabled>Search</button>'
// Instead of (default behaviour):
// '<button class="btn btn-primary" id="1" type="button" disabled>Search</button>'
FAQs
Promise-based API to sort html attributes.
The npm package html-attrs-sorter-promisified receives a total of 0 weekly downloads. As such, html-attrs-sorter-promisified popularity was classified as not popular.
We found that html-attrs-sorter-promisified 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.