
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
Smolder (it's-a-mold-er - sorry) is a JavaScript library wrapper which aims to reshape the input to functions to match a provided schema. It's kind of like casting on speed.
The actual reshaping is done using Reshaper.
npm install smolder
Smolder(library, [schema])library: The JavaScript library to be wrapped. This should be imported - you can do Smolder(require('your library')), for example.[schema]: The schema for the library's functions. This can also be included within the library itself, as shown in the examples.If we have a library, arrays.js, which looks like this:
module.exports = {
sumArray: function (array) {
return arr.reduce(function(a, b) {
return a + b;
});
}
};
And we have some data on people:
var peopleData = [
{
name: 'Joel',
info: {
age: 22,
height: 1.9,
middleName: 'Robert',
lastName: 'Auterson'
}
},
{
name: 'Jake',
info: {
age: 24,
height: 1.85,
middleName: 'Wild',
lastName: 'Hall'
}
}
];
We can use Smolder to apply the sumArray function to the data above, and still get the result we want.
// First let's create a schema for the arrays library.
var schema = {
sumArray: {
array: ['Number'] // Parameter 'array' must be an array of numbers.
}
}
var Smolder = require('smolder');
// Smolder will wrap the arrays library for us
var arrays = Smolder(require('arrays'), schema);
arrays.sumArray(peopleData);
// => 46
The reshaping process will by default use the first match it finds. In the above case, it creates an array using the age values.
If we want to use something other than the default, we can provide Smolder with 'hints', like so:
var hints = {
array: 'height' // We want to sum the heights, not the ages.
};
arrays.sumArray(peopleData, hints);
// => 3.75
It's also possible to just provide Smolder with a string or array of strings as the hint. In this case, it'll use this hint for all parameters.
arrays.sumArray(peopleData, 'height');
// => 3.75
If we're using a library we created, we can build it with support for Smolder out-of-the-box. We just need to add the schema to the library's exports, like so:
module.exports = {
__SMOLDER_SCHEMA: {
sumArray: {
array: ['Number']
}
},
sumArray: function (array) {
var result = 0;
for (var i = 0; i < array.length; i++) {
result += array[i];
}
return result;
}
};
We can then require through Smolder without specifying a schema:
var arrays = Smolder(require('arrays'));
For any function or parameter where a schema is not specified, it won't be changed by the Smolder wrapper.
FAQs
A library wrapper that attempts to reshape data going into your functions.
The npm package smolder receives a total of 3 weekly downloads. As such, smolder popularity was classified as not popular.
We found that smolder 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 Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.