Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extruder

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extruder

Functional tools for processing node-task input objects.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
decreased by-53.06%
Maintainers
1
Weekly downloads
 
Created
Source

extruder

Functional, promise-based tools for processing node-task input objects.

API

extruder.map

Iterate over node-task inputs and map their sources for transformation by a provided callback. Return a promise which resolves to the modified input.

extruder.map(input, fn, context)
  • input A node-task input object.
  • fn A method to be invoked for each source item. Its return value (can be a promise) will replace each source item. fn(source, dest)
  • context The context the fn will be called with.
var extruder = require('./lib/extruder');
var sources = ['path/to/source1', 'path/to/source2'];
extruder.map(sources, function(source, dest) {
  return source+'mapped';
}).then(function(result) {
  console.log(result); // ['path/to/source1mapped', 'path/to/source2mapped'];
});

var sourceDestPairs = [
  { src: 'path/to/source1', dest: 'path/to/dest' },
  { src: ['path/to/source2', 'path/to/source3'], dest: 'path/to/dest' }
];
extruder.map(sourceDestPairs, function(source, dest) {
  return source+'mapped';
}).then(function(result) {
  console.log(result); // [ { src: 'path/to/source1', dest: 'path/to/dest' },
                       // { src: 'path/to/source2-path/to/source3, dest: 'path/to/dest' } ]
});

extruder.reduce

Iterate over node-task inputs and reduce their sources with a provided callback. Return a promise which resolves to the modified input.

extruder.reduce(input, fn, context)
  • input A node-task input object.
  • fn A method to be invoked for each source array. Its return value (can be a promise) will replace each source array. fn(source, dest)
  • context The context the fn will be called with.
var extruder = require('extruder');
var sources = ['path/to/source1', 'path/to/source2'];
extruder.reduce(sources, function(sources, dest) {
  return sources.join('-');
}).then(function(result) {
  console.log(result); // 'path/to/source1-path/to/source2';
});

var sourceDestPairs = [
  { src: 'path/to/source1', dest: 'path/to/dest' },
  { src: ['path/to/source2', 'path/to/source3'], dest: 'path/to/dest' }
];
extruder.reduce(sourceDestPairs, function(sources, dest) {
  return sources.join('-');
}).then(function(result) {
  console.log(result); // [ { src: 'path/to/source1', dest: 'path/to/dest' },
                       //   { src: 'path/to/source2-path/to/source3', dest: 'path/to/dest' } ]
});

Keywords

FAQs

Package last updated on 11 Jun 2013

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc