index.js (1804B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 /** 22 * Map values from one object to a new object having the same keys. 23 * 24 * @module @stdlib/utils/async/map-values 25 * 26 * @example 27 * var stat = require( 'fs' ).stat; 28 * var mapValuesAsync = require( '@stdlib/utils/async/map-values' ); 29 * 30 * function getStats( file, next ) { 31 * stat( file, onStats ); 32 * 33 * function onStats( error, data ) { 34 * if ( error ) { 35 * return next( error ); 36 * } 37 * next( null, data ); 38 * } 39 * } 40 * 41 * // Define a callback which handles errors: 42 * function done( error, out ) { 43 * if ( error ) { 44 * throw error; 45 * } 46 * console.log( out ); 47 * } 48 * 49 * // Create a dictionary of file names: 50 * var files = { 51 * 'file1': './beep.js', 52 * 'file2': './boop.js' 53 * }; 54 * 55 * var opts = { 56 * 'series': true 57 * }; 58 * 59 * // Process each file in `files`: 60 * mapValuesAsync( files, opts, getStats, done ); 61 */ 62 63 // MODULES // 64 65 var setReadOnly = require( './../../../define-nonenumerable-read-only-property' ); 66 var mapValuesAsync = require( './map_values.js' ); 67 var factory = require( './factory.js' ); 68 69 70 // MAIN // 71 72 setReadOnly( mapValuesAsync, 'factory', factory ); 73 74 75 // EXPORTS // 76 77 module.exports = mapValuesAsync;