
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
#EveryCSS
Framework for CSS post and/or pre proccessors.
EveryCSS parses CSS with pre-processors in mind. It parses regular CSS but also non regular CSS like nested rules. By doing this it let you process your css in a pre, post or both ways.
##Caution
EveryCSS is not yet production ready. It actually works but the API is subject to change.
##How it works
EveryCSS:
processors
you set in order to process (edit) ittoString
methodvar EveryCSS = require('everycss'),
// load processors you want to use
importer = require('everycss-import'),
rem = require('everycss-rem'),
nestedRule = require('everycss-nested'),
charset = require('everycss-charset'),
everycss;
// instantiate EveryCSS
everycss = new EveryCSS;
everycss
// add processors
.use(importer.processor)
.use(rem.processor)
.use(nestedRule.processor)
.use(charset.processor)
// process
.processFile('demo/demo.css', function (root) {
// output result
console.log(root.toString());
});
##What is a processor?
A processor is a function which take node tree as parameter and edit it. You can write your own processors and/or use existing ones:
##The EveryCSS object
To create your own pre/post processor, instantiate an EveryCSS object and add processors:
var EveryCSS = require('everycss'),
ecss;
ecss = new EveryCSS;
ecss.use(function (root) {
// process
// call next processor
this.next();
});
Then process a string with process
method or a file with processFile
:
ecss.processFile('somefile.ecss', function (processed) {
console.log(processed.toString());
});
###use(processor
[, options
])
Add a processor to your EveryCSS instance.
processor
: function processing an EveryCSS treeoptions
: object with options used by the processorecssRem = require('everycss/lib/processors/rem');
ecss.use(ecssRem, {size: 10});
###process(string
[, success
[, error
]])
Parse and process a string.
string
: string to processsuccess
: function called when process succeedserror
: function called when process failsecss.process('foo { height: 2rem; }',
function (processed) {
// process succeed
console.log(processed.toString());
},
function (error) {
// process failed
console.log(error);
});
###processFile(filename
[, success
[, error
]])
Parse and process a file.
filename
: file to processsuccess
: function called when process succeedserror
: function called when process failsecss.process('somefile.ecss',
function (processed) {
// process succeed
console.log(processed.toString());
},
function (error) {
// process failed
console.log(error);
});
##The tree
The EveryCSS tree is compound of different types of nodes:
They have common methods and attributes but some types of nodes have their own too. Node methods return the current instance by default.
###Common attributes
type
: type of the node (readonly)iBlock
: if the node could have children (readonly)parent
: the parent node or null (readonly)children
: array of children node (readonly)length
: number of children node (readonly)depth
: depth of the node in the tree (readonly)###Common methods
####children([ type
])
Return node's children. If a type
is provided, only nodes with corresponding type will be returned.
type
: type of node to return####after(node
)
Insert a node
after this in the parent node.
node
: the node to insert####append(node
)
Insert a node
after the last one.
node
: the node to insert####before(node
)
Insert a node
before the current node in the parent.
node
: the node to insert####copy([ overlay
])
Return a copy of the current node.
overlay
: object of properties to replace in the copy####detach()
Remove the current node from it's parent.
####each([ type
,][ limit
,] callback
)
Loop through node's descendant eventually filtered by a type and limited in depth.
type
: type of node to loop through. Loop through all types by defaultlimit
: descending levels allowed. A limit of 0
will loop through direct children. -1
correspond to no limit.callback
: callback called on each node. Receives the node and a loop object as argument.root.each(function (node, loop) {});
root.each(0, function (node, loop) {});
root.each('at-rule', function (rule, loop) {});
root.each('at-rule', 0, function (rule, loop) {});
The callback is executed in the context of the node on which you called each
(the parent node). The callback receives two argument, a descendant node
and a loop
object containing these attributes:
cursor
: global index of the node, depth agnosticdepth
: relative depth of the nodeindex
: index of the node at the current depthdescent
: set to true by default. Defining it to false will prevent from looping on current node's children.####insertAt(node
, index
)
Insert a node
at the given index.
node
: the node to insertindex
: the new position of the node####prepend(node
)
Insert a node
before the first one.
node
: the node to insert####remove(node
)
Remove the node
from the children list.
node
: the node to removeFAQs
Framework for CSS post and/or pre proccessors
The npm package everycss receives a total of 18 weekly downloads. As such, everycss popularity was classified as not popular.
We found that everycss 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
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.