How to use merge-deep - 9 common examples

To help you get started, we’ve selected a few merge-deep 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 alphagov / paas-admin / src / components / org-users / org-users.ts View on Github external
cf.hasOrganizationRole(params.organizationGUID, ctx.token.userID, 'org_manager'),
    cf.hasOrganizationRole(params.organizationGUID, ctx.token.userID, 'billing_manager'),
  ]);

  /* istanbul ignore next */
  if (!isAdmin && !isManager) {
    throw new NotFoundError('not found');
  }

  const [organization, spaces, orgUsers] = await Promise.all([
    cf.organization(params.organizationGUID),
    cf.orgSpaces(params.organizationGUID),
    cf.usersForOrganization(params.organizationGUID),
  ]);
  const errors = [];
  const values: IUserPostBody = merge({
    org_roles: {[params.organizationGUID]: {}},
    space_roles: {},
  }, body);

  const user = orgUsers.find((u: IOrganizationUserRoles) => u.metadata.guid === params.userGUID);

  try {
    if (Object.keys(values.org_roles[params.organizationGUID]).length === 0
      && Object.keys(values.space_roles).length === 0) {
      errors.push({field: 'roles', message: 'at least one role should be selected'});
    }

    if (errors.length > 0) {
      throw new ValidationError(errors);
    }
github smooth-code / smooth.js / packages / smooth / src / config / index.js View on Github external
async function mergeLocalConfig(configPath, defaultConfig) {
  const configExists = await exists(configPath)

  if (!configExists) {
    return defaultConfig
  }

  // eslint-disable-next-line global-require, import/no-dynamic-require
  const localConfig = babelRequire(configPath)
  const config = merge(defaultConfig, localConfig)
  if (localConfig.webpack) config.webpack = localConfig.webpack
  if (localConfig.webpackDevMiddleware)
    config.webpackDevMiddleware = localConfig.webpackDevMiddleware
  return config
}
github mattermost / mattermost-webapp / e2e / cypress / support / api_commands.js View on Github external
cy.request('/api/v4/config').then((response) => {
        const oldSettings = response.body;

        const settings = merge(oldSettings, newSettings);

        // # Set the modified settings
        cy.request({
            url: '/api/v4/config',
            headers: {'X-Requested-With': 'XMLHttpRequest'},
            method: 'PUT',
            body: settings,
        });
    });
github gregberge / svgr / packages / plugin-prettier / src / index.js View on Github external
export default function prettierPlugin(code, config, state) {
  if (!config.prettier) return code
  const filePath = state.filePath || process.cwd()
  const prettierRcConfig = config.runtimeConfig
    ? prettier.resolveConfig.sync(filePath, { editorconfig: true })
    : {}
  return prettier.format(
    code,
    mergeDeep(
      { parser: 'babel' },
      prettierRcConfig,
      config.prettierConfig || {},
    ),
  )
}
github smooth-code / jest-puppeteer / packages / jest-environment-puppeteer / src / readConfig.js View on Github external
import fs from 'fs'
import path from 'path'
import { promisify } from 'util'
import cwd from 'cwd'
import merge from 'merge-deep'

const exists = promisify(fs.exists)

const DEFAULT_CONFIG = {
  launch: {},
  browser: 'chromium',
  browserContext: 'default',
  exitOnPageError: true,
}
const DEFAULT_CONFIG_CI = merge(DEFAULT_CONFIG, {
  launch: {
    args: [
      '--no-sandbox',
      '--disable-setuid-sandbox',
      '--disable-background-timer-throttling',
      '--disable-backgrounding-occluded-windows',
      '--disable-renderer-backgrounding',
    ],
  },
})

export async function readConfig() {
  const defaultConfig =
    process.env.CI === 'true' ? DEFAULT_CONFIG_CI : DEFAULT_CONFIG

  const hasCustomConfigPath = !!process.env.JEST_PUPPETEER_CONFIG
github eunikitin / modern-package-boilerplate / builder / configs / rollup.config.js View on Github external
...cBabelrc,
    }),
    commonjs(),
  ],
};

const development = merge(
  base,
  {
    output: {
      sourcemap: true,
    },
  },
);

const production = merge(
  base,
  {
    plugins: [
      uglify({
        compress: {
          pure_getters: true,
          unsafe: true,
          unsafe_comps: true,
          warnings: false,
        },
      }),
    ],
  },
);
github gregberge / svgr / packages / plugin-svgo / src / index.js View on Github external
function createSvgo(config, rcConfig) {
  const mergedConfig = mergeDeep(
    getBaseSvgoConfig(config),
    rcConfig,
    config.svgoConfig,
  )
  return new SVGO(mergedConfig)
}
github aya-experience / citation / citation-server / src / gitasdb / inspect.js View on Github external
async function inspectMap(map, stack, modelTypes) {
	const [listOfLinks, listOfLink] = partition(values(map), isArray);
	const linksInspections = await Promise.all(
		listOfLinks.map(async links => inspectLinks(links, stack, modelTypes))
	);
	const linkInspections = await Promise.all(
		listOfLink.map(async link => {
			const inspection = await inspectLink(link, stack, modelTypes);
			return { [`... on ${link.type}`]: inspection };
		})
	);
	return {
		_value_: mergeDeep({}, ...linkInspections),
		_list_: mergeDeep({}, ...linksInspections)
	};
}
github aya-experience / citation / citation-server / src / gitasdb / inspect.js View on Github external
async function inspectMap(map, stack, modelTypes) {
	const [listOfLinks, listOfLink] = partition(values(map), isArray);
	const linksInspections = await Promise.all(
		listOfLinks.map(async links => inspectLinks(links, stack, modelTypes))
	);
	const linkInspections = await Promise.all(
		listOfLink.map(async link => {
			const inspection = await inspectLink(link, stack, modelTypes);
			return { [`... on ${link.type}`]: inspection };
		})
	);
	return {
		_value_: mergeDeep({}, ...linkInspections),
		_list_: mergeDeep({}, ...linksInspections)
	};
}

merge-deep

Recursively merge values in a javascript object.

MIT
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis

Popular merge-deep functions