How to use extend-shallow - 10 common examples

To help you get started, we’ve selected a few extend-shallow 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 rolldown / rolldown / src / utils.js View on Github external
const getDefaults = (options, pkg) => {
  options = extend({}, pkg.rollup, options)
  options = pkg.rollupConfig ? extend(options, pkg.rollupConfig) : options
  options = pkg.config && pkg.config.rollup ? extend(options, pkg.config.rollup) : options
  options.onwarn = typeof options.onwarn === 'function'
    ? options.onwarn
    : (er) => {}

  // smart resolving for plugins
  options.plugins = arrayify(options.plugins).map((plugin) => {
    if (typeof plugin === 'string') {
      return require('rollup-plugin-' + plugin)()
    }
    if (Array.isArray(plugin)) {
      const fn = typeof plugin[0] === 'function'
        ? plugin[0]
        : require('rollup-plugin-' + plugin[0])
github rolldown / rolldown / src / utils.js View on Github external
const getDefaults = (options, pkg) => {
  options = extend({}, pkg.rollup, options)
  options = pkg.rollupConfig ? extend(options, pkg.rollupConfig) : options
  options = pkg.config && pkg.config.rollup ? extend(options, pkg.config.rollup) : options
  options.onwarn = typeof options.onwarn === 'function'
    ? options.onwarn
    : (er) => {}

  // smart resolving for plugins
  options.plugins = arrayify(options.plugins).map((plugin) => {
    if (typeof plugin === 'string') {
      return require('rollup-plugin-' + plugin)()
    }
    if (Array.isArray(plugin)) {
      const fn = typeof plugin[0] === 'function'
        ? plugin[0]
        : require('rollup-plugin-' + plugin[0])

      return fn(plugin[1])
    }
github tunnckoCore / opensource / packages / koa-better-body / src / utils.js View on Github external
export function defaultOptions(options = {}) {
  const cfg = { ...options };

  const types = defaultTypes(cfg.extendTypes);
  const opts = extend(
    {
      fields: false,
      files: false,
      multipart: true,
      textLimit: false,
      formLimit: false,
      jsonLimit: false,
      jsonStrict: true,
      detectJSON: false,
      bufferLimit: false,
      buffer: false,
      strict: true,

      // query string `parse` options
      delimiter: '&',
      decodeURIComponent: querystring.unescape,
github rolldown / rolldown / src / utils.js View on Github external
// plugin for `ongenerate` and `onwrite` hooks
  options.plugins.push({
    name: 'rolldown-hooks',
    onwrite: (opts) => (
      typeof options.onwrite === 'function' && options.onwrite(opts)
    ),
    ongenerate: (opts) => (
      typeof options.ongenerate === 'function' && options.ongenerate(opts)
    )
  })

  // prevent rollup from throwing
  // if unknown options is passed
  // such as `options.ongenerate`
  // and `options.onwrite`
  const opts = extend({}, options)
  delete opts['ongenerate']
  delete opts['onwrite']

  return opts
}
github rolldown / rolldown / src / utils.js View on Github external
const getDefaults = (options, pkg) => {
  options = extend({}, pkg.rollup, options)
  options = pkg.rollupConfig ? extend(options, pkg.rollupConfig) : options
  options = pkg.config && pkg.config.rollup ? extend(options, pkg.config.rollup) : options
  options.onwarn = typeof options.onwarn === 'function'
    ? options.onwarn
    : (er) => {}

  // smart resolving for plugins
  options.plugins = arrayify(options.plugins).map((plugin) => {
    if (typeof plugin === 'string') {
      return require('rollup-plugin-' + plugin)()
    }
    if (Array.isArray(plugin)) {
      const fn = typeof plugin[0] === 'function'
        ? plugin[0]
        : require('rollup-plugin-' + plugin[0])

      return fn(plugin[1])
github vkbansal / illuminate-js / src / utils / lang.js View on Github external
throw new Error("Source does not have required property '_order' as an array.");
    }

    if (!isObj(insert) || !insert.hasOwnProperty("_order") || !Array.isArray(insert._order)) {
        throw new Error("insert does not have required property '_order' as an array");
    }

    source._order = diff(source._order, Object.keys(insert));

    let index = source._order.indexOf(before);

    source._order.splice(index, 0, ...insert._order);

    delete insert._order;

    return extendShallow(source, insert);
}
github tunnckoCore / opensource / packages / koa-better-body / src / utils.js View on Github external
export function defaultTypes(types = {}) {
  const allTypes = { ...types };

  return extend(
    {
      multipart: ['multipart/form-data'],
      text: ['text/*'],
      form: ['application/x-www-form-urlencoded'],
      json: [
        'application/json',
        'application/json-patch+json',
        'application/vnd.api+json',
        'application/csp-report',
      ],
      buffer: ['text/*'],
    },
    allTypes,
  );
}
github tunnckoCore / opensource / packages / koa-better-body / dist / module / utils.js View on Github external
export function defaultTypes(types = {}) {
  const allTypes = { ...types
  };
  return extend({
    multipart: ['multipart/form-data'],
    text: ['text/*'],
    form: ['application/x-www-form-urlencoded'],
    json: ['application/json', 'application/json-patch+json', 'application/vnd.api+json', 'application/csp-report'],
    buffer: ['text/*']
  }, allTypes);
}
export function isValid(method) {
github vkbansal / illuminate-js / src / utils / lang.js View on Github external
export function extend(source, ext) {
    let { _order: srcOrder } = source,
        { _order: extOrder, ...props } = ext,
        extKeys = Object.keys(props);

    let newTokens = diff(extKeys, srcOrder);

    let def = clone(source);

    return extendShallow(def, ext, {
        _order: srcOrder.concat(newTokens)
    });
}
github tunnckoCore / opensource / packages / koa-better-body / dist / module / utils.js View on Github external
export function defaultOptions(options = {}) {
  const cfg = { ...options
  };
  const types = defaultTypes(cfg.extendTypes);
  const opts = extend({
    fields: false,
    files: false,
    multipart: true,
    textLimit: false,
    formLimit: false,
    jsonLimit: false,
    jsonStrict: true,
    detectJSON: false,
    bufferLimit: false,
    buffer: false,
    strict: true,
    delimiter: '&',
    decodeURIComponent: querystring.unescape,
    maxKeys: 1000
  }, cfg);
  opts.delimiter = opts.sep || opts.delimiter;

extend-shallow

Extend an object with the properties of additional objects. node.js/javascript util.

MIT
Latest version published 7 years ago

Package Health Score

68 / 100
Full package analysis

Popular extend-shallow functions