test('does not clone sequelize models', function () { var User = this.sequelize.define('user') , merged = Utils.merge({}, { include: [{model : User }]}) , merged2 = Utils.merge({}, { user: User }); expect(merged.include[0].model).to.equal(User); expect(merged2.user).to.equal(User); });
test('does not clone sequelize models', () => { const User = Support.sequelize.define('user'); const merged = Utils.merge({}, { include: [{model : User }]}); const merged2 = Utils.merge({}, { user: User }); expect(merged.include[0].model).to.equal(User); expect(merged2.user).to.equal(User); });
module.exports = function () { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var action = arguments[1]; switch (action.type) { case `DELETE_CACHE`: return {}; case `CREATE_PAGE`: case `CREATE_LAYOUT`: action.payload.componentPath = normalize(action.payload.component); state[action.payload.componentPath] = _.merge({}, state[action.payload.componentPath], { componentPath: action.payload.componentPath }); return state; case `DELETE_PAGE`: action.payload.componentPath = normalize(action.payload.component); delete state[action.payload.componentPath]; return state; case `REPLACE_COMPONENT_QUERY`: action.payload.componentPath = normalize(action.payload.componentPath); state[action.payload.componentPath] = (0, _extends3.default)({}, state[action.payload.componentPath], { query: action.payload.query }); return state; } return state; };
Sequence.prototype.zip = function(query) { var result = new Sequence(); for(var i=0; i<this.sequence.length; i++) { result.push(helper.merge(this.sequence[i].left, this.sequence[i].right, query)); } return result; }
it('should replace values in the original', function() { var original = { a: "a", b: "b" }; var secondary = { a: "c" }; var expected = { a: "c", b: "b" }; merge.merge(original, expected).should.eql(expected); });
tupai.merge('check', meOptions, function(code) { // merge classes to one file if(code == 0) { console.log(' ok'); } else { console.error(' ng'); return; } console.log('merge classes: '); tupai.merge('merge', meOptions, function() { var inputJs = meOptions.output; if(target === 'debug') { // copy it console.log('copy: '); console.log(' ' + inputJs + ' -> ' + outputJs); fs.createReadStream(inputJs) .pipe(fs.createWriteStream(outputJs)); } else { // compress js file console.log('compress: '); console.log(' ' + inputJs + ' -> ' + outputJs); tupai.compress( inputJs, { type: 'js', output: outputJs } ); } }); });
it('should should not merge non-recursively if not speficied', function() { var original = { a: "a", b: ["1", "2", "3"], c: { a: "a", b: "b", c: "c" } }; var secondary = { b: ["1"], c: { a: "a" } }; var expected = { a: "a", b: ["1"], c: { a: "a" } }; merge.merge(original, expected).should.eql(expected); });
it('should merge the passed objects together', function() { var original = { a: "a", b: "b" }; var secondary = { c: "c" }; var expected = { a: "a", b: "b",c: "c" }; merge.merge(original, expected).should.eql(expected); });
it('should should merge recursively if speficied', function() { var original = { a: "a", b: ["1", "2", "3"], c: { a: "a", b: "b", c: "c" } }; var secondary = { b: ["1"], c: { d: "d" } }; var expected = { a: "a", b: ["1", "2", "3", "1"], c: { a: "a", b: "b", c: "c", d: "d" } }; merge.merge(original, expected, true).should.eql(expected); });
module.exports = function () { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { plugins: {} }; var action = arguments[1]; switch (action.type) { case `DELETE_CACHE`: return { plugins: {} }; case `UPDATE_PLUGINS_HASH`: return (0, _extends3.default)({}, state, { PLUGINS_HASH: action.payload }); case `SET_PLUGIN_STATUS`: if (!action.plugin && !action.plugin.name) { throw new Error(`You can't set plugin status without a plugin`); } if (!_.isObject(action.payload)) { throw new Error(`You must pass an object into setPluginStatus. What was passed in was ${JSON.stringify(action.payload, null, 4)}`); } return (0, _extends3.default)({}, state, { plugins: (0, _extends3.default)({}, state.plugins, { [action.plugin.name]: _.merge({}, state.plugins[action.plugin.name], action.payload) }) }); default: return state; } };
module.exports = (state = new Map(), action) => { switch (action.type) { case `DELETE_CACHE`: return new Map() case `CREATE_PAGE`: action.payload.componentPath = normalize(action.payload.component) state.set( action.payload.componentPath, _.merge({ query: `` }, state.get(action.payload.componentPath), { componentPath: action.payload.componentPath, }) ) return state case `REMOVE_TEMPLATE_COMPONENT`: state.delete(normalize(action.payload.componentPath)) return state case `REPLACE_COMPONENT_QUERY`: action.payload.componentPath = normalize(action.payload.componentPath) state.set(action.payload.componentPath, { ...state.get(action.payload.componentPath), query: action.payload.query, }) return state } return state }
module.exports = (state = {}, action) => { switch (action.type) { case `DELETE_CACHE`: return {} case `CREATE_PAGE_COMPONENT`: action.payload.componentPath = normalize(action.payload.componentPath) state[action.payload.componentPath] = _.merge( {}, state[action.payload.componentPath], { componentPath: action.payload.componentPath, } ) return state case `REPLACE_PAGE_COMPONENT_QUERY`: action.payload.componentPath = normalize(action.payload.componentPath) state[action.payload.componentPath] = { ...state[action.payload.componentPath], query: action.payload.query, } return state } return state }
Sequence.prototype.merge = function(toMerge, query) { var result = new Sequence(); for(var i=0; i<this.sequence.length; i++) { result.push(helper.merge(this.sequence[i], toMerge, query)) } return result; }
Sequence.prototype.merge = function(toMerge, query, internalOptions) { var result = new Sequence(); for(var i=0; i<this.sequence.length; i++) { result.push(util.merge(this.sequence[i], toMerge, query, internalOptions)) } return result; }
async function onCreateNode({ node, actions, loadNodeContent, createNodeId, createContentDigest }) { function transformObject(obj, id, type) { const yamlNode = { ...obj, id, children: [], parent: node.id, internal: { contentDigest: createContentDigest(obj), type } }; createNode(yamlNode); createParentChildLink({ parent: node, child: yamlNode }); } const { createNode, createParentChildLink } = actions; if (node.internal.mediaType !== `text/yaml`) { return; } let def = {}; try { def = jsYaml.safeLoad( fs.readFileSync(path.normalize(`${__dirname}/src/data/lang/en_us/index.yaml`), { json: true }) ); } catch (e) { // console.log(e); } const content = await loadNodeContent(node); const parsedContent = jsYaml.safeLoadAll(content); // const parsedContent = _.merge(def, p); if (_.isArray(parsedContent)) { parsedContent.forEach((obj, i) => { if (obj === null) { return; } const o = _.merge(def, obj); transformObject( o, o.id ? o.id : createNodeId(`${node.id} [${i}] >>> YAML`), _.upperFirst(_.camelCase(`${node.name} Yaml`)) ); }); } else if (_.isPlainObject(parsedContent)) { const o = _.merge(def, parsedContent); transformObject( o, o.id ? o.id : createNodeId(`${node.id} >>> YAML`), _.upperFirst(_.camelCase(`${path.basename(node.dir)} Yaml`)) ); } }
parsedContent.forEach((obj, i) => { if (obj === null) { return; } const o = _.merge(def, obj); transformObject( o, o.id ? o.id : createNodeId(`${node.id} [${i}] >>> YAML`), _.upperFirst(_.camelCase(`${node.name} Yaml`)) ); });
it('should deep-merge a user defined config over the default config if deep is set to true', function() { var expected = extend(true, {}, defaultMockup, userConfig); cg = new Config({ path: configPath + configFile }); cg.setDefault(defaultMockup); cg.merge(userConfig, true); cg.get().should.eql(expected); });
function updateDoc(oldDoc, docInfo, callback) { var merged = Pouch.merge(oldDoc.rev_tree, docInfo.metadata.rev_tree[0], 1000); var conflict = (isDeleted(oldDoc) && isDeleted(docInfo.metadata)) || (!isDeleted(oldDoc) && newEdits && merged.conflicts !== 'new_leaf'); if (conflict) { results.push(makeErr(Pouch.Errors.REV_CONFLICT, docInfo._bulk_seq)); return callback(); } docInfo.metadata.rev_tree = merged.tree; docInfo.metadata.rev_map = oldDoc.rev_map; writeDoc(docInfo, callback); }
end: function(code) { if(code != 0) { console.error('gen template files fails'); return; } console.log('gen configs:'); tupai.compileConfigSync( tupaiConfig.configs, tupaiConfig.genConfigs, 'Config' ); console.log('consistency check: '); tupai.merge('check', meOptions, function(code) { // merge classes to one file if(code == 0) { console.log(' ok'); } else { console.error(' ng'); return; } console.log('merge classes: '); tupai.merge('merge', meOptions, function() { var inputJs = meOptions.output; if(target === 'debug') { // copy it console.log('copy: '); console.log(' ' + inputJs + ' -> ' + outputJs); fs.createReadStream(inputJs) .pipe(fs.createWriteStream(outputJs)); } else { // compress js file console.log('compress: '); console.log(' ' + inputJs + ' -> ' + outputJs); tupai.compress( inputJs, { type: 'js', output: outputJs } ); } }); }); }
function requireModel(modelPath){ log('requiring model: '+modelPath) var model = require(modelPath) , domain = (config.domain) ? '/{1}/'.assign(config.domain) : '/' model = srv.m[model.name] = model model.merge(modelExt, false, false) model.fields.forEach( function( field ){ fieldExt( field ) }) if ( !model.avoidGenericController ){ if (model.menu){ var tenant = '' if ( model.multiTenant ) tenant = '{1}/' menuItems.push({menu: model.menu, url: domain + tenant + model.name, label: model.label, onlyFor: model.onlyFor}) } ctrlCrud(srv, base, model, config) } }
Object.keys(state.stages).forEach(stage => { if (action.payload.stage && action.payload.stage !== stage) { return } const index = _.findIndex( state.stages[stage].presets, p => p.name === action.payload.name ) // If the plugin already exists, merge the options. // Otherwise, add it to the end. if (index !== -1) { const plugin = state.stages[stage].presets[index] state.stages[stage].presets[index] = { name: plugin.name, options: _.merge(plugin.options, action.payload.options), } } else { state.stages[stage].presets = [ ...state.stages[stage].presets, action.payload, ] } })
this.queue = async.queue(function(task, callback){ var id = task._id; delete task._id; db.merge(id, task, callback); }, 1);
it('should return a from a,b', function() { var a = {method:'put',value:'a'}; var b = {method:'put',value:'b'}; var expected = {method:'put',value:'a'}; util.merge(a,b).should.eql(expected); });
it('should increment count from a,b', function() { var a = {method:'counter',value:{counter:1}}; var b = {method:'counter',value:{counter:1}}; var expected = { method: 'counter', value: { counter: 2 } }; util.merge(a,b).should.eql(expected); });
it('should return a', function() { var a = {}; util.merge(a).should.eql(a); });
var path = require('path'); var Ember = require(path.join(process.cwd(), 'lib', 'ember')); var Resolver = require(path.join(process.cwd(), 'lib', 'ember-resolver')); var config = require(path.join(process.cwd(), 'config', 'environment'))('development'); var loadInitializers = require(path.join(process.cwd(), 'lib', 'ember-load-initializers')); global.window = { EmberENV: config.EmberENV }; var App = Ember.Application.create(Ember.merge({ modulePrefix: config.modulePrefix, Resolver: Resolver }, config.APP)); loadInitializers(App, config.modulePrefix); module.exports = App;
module.exports = (req, res) => { let data = content.merge(`default`, `home`) res.render(`home`, data) }
Object.keys(files).forEach(file => { const data = files[file]; _.merge(data, matchedMetadata(file, options) || {}); });
it('should merge phrases', () => { T.merge({test_phrase: '123'}); T.t('test_phrase').should.equal('123'); });
Document.prototype.merge = function(obj, query) { return util.merge(this.doc, obj, query); }