
Research
Namastex.ai npm Packages Hit with TeamPCP-Style CanisterWorm Malware
Malicious Namastex.ai npm packages appear to replicate TeamPCP-style Canister Worm tradecraft, including exfiltration and self-propagation.
gradient-parser
Advanced tools
Parse CSS gradient definitions and return an AST object.
var gradient = require('gradient-parser');
var obj = gradient.parse('linear-gradient(30deg, #000, transparent)');
console.log(JSON.stringify(obj, null, 2));
Results in:
[
{
"type": "linear-gradient",
"orientation": {
"type": "angular",
"value": "30",
"unit": "deg"
},
"colorStops": [
{
"type": "hex",
"value": "000"
},
{
"type": "literal",
"value": "transparent"
}
]
}
]
Install via npm:
npm install gradient-parser
Import in Node.js (CommonJS):
const gradient = require('gradient-parser');
Import in Node.js (ESM):
import { parse, stringify } from 'gradient-parser';
For browser usage:
<script src="node_modules/gradient-parser/build/web.js"></script>
Gradient-parser has been modernized (as of v1.1.0):
Gradient-parser uses a modern build system with esbuild for building and minification.
# Build both Node.js and web bundles
npm run build
# Build only Node.js bundle
npm run build:node
# Build only web bundle
npm run build:web
# Build minified bundles
npm run build:minify
Run the test suite with:
npm test
The build step runs automatically before tests via the pretest script.
You can run a simple HTTP server for development:
npm start
Accepts a CSS gradient definition as declared in background-image and returns an AST as an Array of gradient nodes.
var ast = gradient.parse('linear-gradient(to right, red, blue)');
Accepts an AST (as returned by parse) and serializes it back into a CSS gradient string.
var css = gradient.stringify(ast);
// => 'linear-gradient(to right, red, blue)'
Round-trip is supported:
gradient.stringify(gradient.parse(input)) === input
All nodes have the following properties.
String. The possible values are the ones listed in the Types section below.
The available values of node.type are listed below, as well as the available properties of each node (other than the common properties listed above).
Object or undefined. Possible types directional or angular.Array of color stops.Object or undefined. Possible types directional or angular.Array of color stops.Array or undefined. Array of possible types shape, default-radial, extent-keyword.Array of color stops.Array or undefined. Array of possible types shape, default-radial, extent-keyword.Array of color stops.Object or undefined of type conic.Array of color stops.Object or undefined of type conic.Array of color stops.Each color stop has the following properties:
String one of literal, hex, rgb, rgba, hsl, hsla, var.Object or undefined. Position of the color stop (see length types).Object or undefined. Second position for dual-position color stops.String possible values left, top, bottom, right, left top, left bottom, right top, right bottom, top left, top right, bottom left, bottom right.String numeric value of the angle.String one of deg, rad, grad, turn.Object or undefined of type angular.Object or undefined of type position.String literal name of the color.String hex value (3, 4, 6, or 8 digits, without # prefix).Array of length 3 of String numbers.Array of length 4 of String numbers.Array of length 3: [hue, saturation, lightness]. Hue is a String number, saturation and lightness are String numbers without the % suffix.Array of length 4: [hue, saturation, lightness, alpha]. Same as hsl with an additional alpha String number.String the CSS custom property name (e.g. --color-red).'calc'String the raw calc expression content (e.g. 50% + 25px).Object or undefined possible types extent-keyword, px, em, rem, %, position, or position-keyword.String possible values ellipse or circle.Object or undefined of type position.Object of type position.Object with x and y properties, each a length/keyword node.String possible values center, left, top, bottom, or right.String possible values closest-side, closest-corner, farthest-side, farthest-corner, contain, or cover.Length nodes can be any of: px, em, rem, vw, vh, vmin, vmax, ch, ex, %, calc.
String numeric value (for calc, the expression string).(The MIT License)
Copyright (c) 2014-2025 Rafael Caricio rafael@caricio.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The css-gradient-parser package is another tool for parsing CSS gradient strings. It provides similar functionality to gradient-parser, allowing users to convert gradient strings into a JSON format. However, css-gradient-parser may have different parsing rules or support for additional gradient types, making it a potential alternative depending on specific needs.
PostCSS is a tool for transforming CSS with JavaScript plugins. While not specifically focused on gradients, it can be extended with plugins to parse and manipulate CSS, including gradients. Compared to gradient-parser, PostCSS offers a broader range of CSS processing capabilities, making it suitable for more comprehensive CSS transformations.
FAQs
Parse CSS3 gradient definitions and return an AST.
We found that gradient-parser demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Research
Malicious Namastex.ai npm packages appear to replicate TeamPCP-style Canister Worm tradecraft, including exfiltration and self-propagation.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.