
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
fields-transformer
Advanced tools
Typically transforms key value pairs into some other key value pairs. It is intended to work with the results from multipart handlers like formidable or multer. Not the transformer from the transformer
movie.
See documentation below.
Use the package manager npm to install field-transformer.
npm install field-transformer
const transformer = require('jwt-linker');
Use the make
method for transforming an object
with keys with values of type array of objects
transformer.make({
bread: [{path: 'a'}, {path: 'b'}, {path: '...n'}],
butter: [{path: 'a'}, {path: 'b'}, {path: '...n'}],
ginger: [{path: 'a'}, {path: 'b'}, {path: '...n'}]
});
// Typically, used with transformer.attach
Use to transform an array
of paths
into an array of filePaths
like so
const {filePaths} = transformer.makeSingle({
files: [{path: 'a'}, {path: 'b'}, {path: '...n'}]}
);
console.log(filePaths); // ['a', 'b', '..n']
Use to transform keys of values of type object
with path
as values into an array of filePaths
like so
const {filePaths} = transformer.objFieldTransformer({
bread: {path: 'a'},
butter: {path: 'a'},
ginger: {path: 'a'},
});
console.log(filePaths); // ['a', 'a', 'a']
Use to transform keys of values of the type array
into an array of filePaths
like so
const someObject = {
bread: [{path: 'a'}, {path: 'b'}, {path: '...n'}],
butter: [{path: 'a'}, {path: 'b'}, {path: '...n'}],
ginger: [{path: 'a'}, {path: 'b'}, {path: '...n'}]
};
const {filePaths} = transformer.objArrayTransformer(someObject);
console.log(filePaths); // ['a', 'b', '..n', 'a', 'b', '..n', ...]
Use to attach elements of the filePaths to the doc. Receives two arguments doc
and fields
.
Fields
is either an array of strings or just a string. Attach picks the values from the filePaths
in transformer.make
returns a promise, deal as suites you.
const docModified = await transformer.attach({}, ['storyImages', 'otherImages']);
or const docModified = await transformer.attach({}, 'profileImage');
console.log({docModified}); // {docModified: {storyImages: '...', otherImages: '...'}}
or console.log({docModified}); // {docModified: {profileImage: '...'}}
Please visit the Github repo. Submissions, issues... are welcome
FAQs
transforms fields
The npm package fields-transformer receives a total of 11 weekly downloads. As such, fields-transformer popularity was classified as not popular.
We found that fields-transformer 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.