How to use the value-or-function.number function in value-or-function

To help you get started, we’ve selected a few value-or-function examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gulpjs / vinyl-fs / lib / dest / make-dirs.js View on Github external
'use strict';

var through = require('through2');
var valueOrFunction = require('value-or-function');

var fo = require('../file-operations');

var number = valueOrFunction.number;

function makeDirs(opt) {

  function makeFileDirs(file, enc, callback) {
    // TODO: Can this be put on file.stat?
    var dirMode = number(opt.dirMode, file);

    fo.mkdirp(file.dirname, dirMode, onMkdirp);

    function onMkdirp(mkdirpErr) {
      if (mkdirpErr) {
        return callback(mkdirpErr);
      }
      callback(null, file);
    }
  }
github gulpjs / vinyl-fs / lib / prepare-write.js View on Github external
'use strict';

var assign = require('object-assign');
var path = require('path');
var fs = require('graceful-fs');
var valueOrFunction = require('value-or-function');
var koalas = require('koalas');

var fo = require('./file-operations');

var boolean = valueOrFunction.boolean;
var number = valueOrFunction.number;
var string = valueOrFunction.string;

function prepareWrite(outFolder, file, opt, callback) {
  if (!opt) {
    opt = {};
  }

  var defaultMode = file.stat ? file.stat.mode : null;
  var options = assign({}, opt, {
    cwd: koalas(string(opt.cwd, file), process.cwd()),
    mode: koalas(number(opt.mode, file), defaultMode),
    dirMode: number(opt.dirMode, file),
    overwrite: koalas(boolean(opt.overwrite, file), true),
  });
  options.flag = (options.overwrite ? 'w' : 'wx');

value-or-function

Normalize a value or function, applying extra args to the function

MIT
Latest version published 3 years ago

Package Health Score

66 / 100
Full package analysis