Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
unmarshaller
Advanced tools
Toolbox for configuration
npm install --save unmarshaller
import {builder, unmarshal} from 'unmarshaller';
const unmarshaller = {
editor: builder.string('EDITOR'),
browser: builder.string('BROWSER'),
};
const lookupFn = (key) => process.env[key];
const config = unmarshal(lookupFn, unmarshaller);
console.log(config);
You need to provide to the unmarshal
function a way to lookup from keys in configuration.
The example above returns the value found in the process's environment:
const lookupFn = (key) => process.env[key];
Just an object which represents your configuration.
Helper functions to build the unmarshaller object.
type |
---|
string |
boolean |
number |
object |
holder |
or |
name | type | description |
---|---|---|
defaultValue | string | fallback value if the lookup returned undefined or null |
of | array | provide an enumeration of possible values |
parser | function | provide an custom parser function (usually when you want your own types) |
const unmarshaller = {
foo: builder.or(
builder.string('foo_a'),
builder.string('foo_b'),
)
};
The unmarshalling process will call the lookup function until a value (not undefined or null) is returned.
import {extend, builder} from 'unmarshaller';
const holder = builder.holder({
editor: builder.string('EDITOR'),
browser: builder.string('BROWSER'),
});
const extendedHolder = extend(holder, {
version: builder.string('VERSION'),
});
The builder is a regular JavaScript object.
Customizing the builder gives you the possiblity to use your own data converters.
The following example use a custom type: color
(which in my use case parses a string into a structure).
import {builder as defaultBuilder} from 'unmarshaller';
export const builder = {
...defaultBuilder,
color: (name, options) => ({
name,
parser: parseColor,
type: 'color',
...options
}),
};
You need to provide a custom parser function (parseColor
in the example above).
The definition is: function(value: string): string
.
FAQs
Toolbox for configuration
The npm package unmarshaller receives a total of 2 weekly downloads. As such, unmarshaller popularity was classified as not popular.
We found that unmarshaller demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.