export const deploy = co.wrap(function *(files, options, AWSOptions, s3Options, clientOptions = {}) { AWSOptions = clone(AWSOptions, true); s3Options = clone(s3Options, true); const cwd = options.cwd; const filePrefix = options.filePrefix || ''; AWS.config.update(Object.assign({ sslEnabled: true }, AWSOptions)); var client = new AWS.S3(clientOptions); yield Promise.all(files.map(function(filePath) { return handleFile(filePath, cwd, filePrefix, client, s3Options); })); });
function builder() { if (arguments.length > keys.length) { throw new Error( `t.${type}: Too many arguments passed. Received ${arguments.length} but can receive ` + `no more than ${keys.length}` ); } let node = {}; node.type = type; let i = 0; for (let key of (keys: Array<string>)) { let field = t.NODE_FIELDS[type][key]; let arg = arguments[i++]; if (arg === undefined) arg = loClone(field.default); node[key] = arg; } for (let key in node) { validate(node, key, node[key]); } return node; }
/** * Invoked when a user submits the <QueryForm>. * @param {Event|Object} e The native or React event. */ function handleSubmit(e) { e.preventDefault(); let paramsClone = clone(params.get()); // Construct a "Query Parameter" dimension string based off this report let paramsToTrack = pick(paramsClone, ['start-date', 'end-date', 'metrics', 'dimensions']); // Don't run `encodeURIComponent` on these params because the they will // never contain characters that make parsing fail (or be ambiguous). // NOTE: Manual serializing is requred until the encodeURIComponent override // is supported here: https://github.com/Gozala/querystring/issues/6 let serializedParamsToTrack = map(paramsToTrack, (value, key) => `${key}=${value}`).join('&'); // Set it on the tracker so it gets sent with all Query Explorer hits. ga('set', 'dimension2', serializedParamsToTrack); state.set({ isQuerying: true, report: { params: paramsClone } }); }
Dispatcher.prototype._dispatch = function(action) { if(!action || !action.type) { throw new Error('Can only dispatch actions with a \'type\' property'); } if(this.currentDispatch) { var complaint = 'Cannot dispatch an action (\'' + action.type + '\') while another action (\'' + this.currentActionType + '\') is being dispatched'; throw new Error(complaint); } this.waitingToDispatch = _clone(this.stores); this.currentActionType = action.type; this.currentDispatch = _mapValues(this.stores, function() { return { resolved: false, waitingOn: [], waitCallback: null }; }); try { this.doDispatchLoop(action); } finally { this.currentActionType = null; this.currentDispatch = null; } };
function destroySuccess(state, action) { const books = clone(state.books) books.splice(indexOfBook(state, action.id), 1) return { ...state, books } }
function CharmeleonWatcher(opts){ delete require.cache[__filename]; this._childCwd = path.dirname(module.parent.filename); this.closed = false; // from chokidar this._child = null; this._paths = []; this._opts = clone(opts); }
/** * Invoked when a user submits the <QueryForm>. * @param {Event|Object} e The native or React event. */ function handleSubmit(e) { e.preventDefault(); state.set({ isQuerying: true, report: { params: clone(params.get()) } }); }
it('should work with arrays inside JSON', function() { var cameledPostCloned = iwUtils.toCamel(clone(postJson, true)); cameledPostCloned.categories[0].name = 'Linux'; var syncedObject = iwUtils.syncObjects(postJson, cameledPostCloned); assert.equal(syncedObject.categories[0].name, 'Linux'); });
/** * Invoked when the DataChart component's "error" event emits. * @param {Object} data The error emitted by the DataChart's "error" event. */ function handleDataChartError(err) { state.set({ isQuerying: false, report: { accountData: clone(state.get('selectedAccountData')), params: state.get('report').params, error: err.error } }); }
this.__adapter.onDone((attr) => { /** * GET Resource case */ this.attr = toCamel(clone(attr, true)); storage.store(this); original[this.type + this.__unique] = attr; defer.resolve(this); }).ajax('get', this.address, false);
/** * Invoked when the DataChart component's "success" event emits. * @param {Object} data The object emitted by the DataChart's "success" event. */ function handleDataChartSuccess(data) { state.set({ isQuerying: false, report: { accountData: clone(state.get('selectedAccountData')), params: state.get('report').params, response: data.response } }); }
static createBareOptions() { let opts = {}; for (let key in config) { let opt = config[key]; opts[key] = clone(opt.default); } return opts; }
function updateSuccess(state, action) { const books = clone(state.books) books[indexOfBook(state, action.book.id)] = action.book return { ...state, updateBook: action.book, updateBooksErrors: [], books, updateIsSuccess: true } }
constructor(plugin: Object) { super(); this.initialized = false; this.raw = assign({}, plugin); this.manipulateOptions = this.take("manipulateOptions"); this.post = this.take("post"); this.pre = this.take("pre"); this.visitor = this.normalize(clone(this.take("visitor")) || {}); }
exports.Property = function (node, parent, scope, context, file) { if (node.method) { node.method = false; nameMethod.property(node, file, scope); } if (node.shorthand) { node.shorthand = false; node.key = t.removeComments(clone(node.key)); } };
function createElement(w, h, type, deParent, onload) { var de = document.createElement(type) de.style.width = w + 'px' de.style.height = h + 'px' de.style.backgroundColor = takeOne(colors) de.style.boxShadow = '1px 1px 4px 0px rgba(50, 50, 50, 0.75)' de._handlerTransform = clone(INIT_TRANSFORM) de.onload = onload place(de, deParent) return de }
it('should work with large JSON objects', function() { var cameledPostCloned = iwUtils.toCamel(clone(postJson, true)), syncedObject; cameledPostCloned.processedCover = 'test.jpg'; cameledPostCloned.blog.userBlog.blog.domainChangeCount = 100; cameledPostCloned.blog.userBlog.onepager.processedCover = 'img.jpg'; syncedObject = iwUtils.syncObjects(postJson, cameledPostCloned); assert.equal(syncedObject.processed_cover, 'test.jpg'); assert.equal(syncedObject.blog.user_blog.blog.domain_change_count, 100); assert.equal(syncedObject.blog.user_blog.onepager.processed_cover, 'img.jpg'); });
AlgoliaSearchParse.prototype._request = function(rawUrl, opts) { /* global Parse */ var clone = require('lodash/lang/clone'); var promise = new Parse.Promise(); debug('url: %s, opts: %j', rawUrl, opts); var parseReqOpts = { url: rawUrl, headers: clone(opts.headers), method: opts.method, success: success, error: error }; if (opts.body) { // parse is proxing our requests and requires us to set a charset. while json is always utf-8 parseReqOpts.headers['content-type'] = 'application/json;charset=utf-8'; parseReqOpts.body = opts.body; } Parse.Cloud.httpRequest(parseReqOpts); function error(res) { debug('error: %j - %s %j', res, rawUrl, opts); // we still resolve, bc Parse does not distinguish network errors // from 400/500 statuses promise.resolve({ statusCode: res.status, body: res.data, headers: res.headers }); } function success(res) { debug('success: %j - %s %j', res, rawUrl, opts); promise.resolve({ statusCode: res.status, body: res.data, headers: res.headers }); } return promise; };
const compact = (o) => { let cloned = clone(o); if (isArray(cloned) || isPlainObject(cloned)) { each(cloned, (v, k) => { let newV = compact(v); if (isEmpty(newV) && !isNumber(newV) && !isBoolean(newV)) { delete cloned[k]; } else { cloned[k] = newV; } }); } return cloned; };
var end = function () { var opts2 = clone(opts); delete opts2.sourceMapRelative; delete opts2.extensions; delete opts2.global; opts2.filename = filename; try { var out = babel.transform(data, opts2).code; } catch(err) { stream.emit("error", err); stream.queue(null); return; } stream.queue(out); stream.queue(null); };
/** * Invoked when the DataChart component's "error" event emits. * @param {Object} data The error emitted by the DataChart's "error" event. */ function handleDataChartError(err) { state.set({ isQuerying: false, report: { accountData: clone(state.get('selectedAccountData')), params: state.get('report').params, error: err.error } }); ga('send', { hitType: 'event', eventCategory: 'query', eventAction: 'submit', eventLabel: `(${err.error.code}) ${err.error.message}`, metric2: 1 }); }
/** * Invoked when the DataChart component's "success" event emits. * @param {Object} data The object emitted by the DataChart's "success" event. */ function handleDataChartSuccess(data) { state.set({ isQuerying: false, report: { accountData: clone(state.get('selectedAccountData')), params: state.get('report').params, response: data.response } }); ga('send', { hitType: 'event', eventCategory: 'query', eventAction: 'submit', eventLabel: '(200) OK', metric1: 1 }); }
/** * Invoked when a user changes the ViewSelector2 instance. * @param {Object} data The object emited by the ViewSelector2's "changeView" * event. */ function handleViewSelectorChange(data) { let {account, property, view} = data; params.set('ids', data.ids); state.set('selectedAccountData', clone(data)); tagData.getMetricsAndDimensions( account, property, view).then(function(data) { metrics = data.metrics; dimensions = data.dimensions; // TODO(philipwalton) This does need to happen after metrics and dimensions // potentially change, but it sould probably happen in an event handler // rather than here. Refactor once dimensions and metrics are moved to // be properties of `state`. setSortOptions(); render(); }); }
bindLeafletEvents(next = {}, prev = {}) { const el = this.leafletElement; if (!el) return; const diff = clone(prev); forEach(prev, (cb, ev) => { if (!next[ ev ] || cb !== next[ ev ]) { delete diff[ ev ]; el.off(ev, cb); } }); forEach(next, (cb, ev) => { if (!prev[ ev ] || cb !== prev[ ev ]) { diff[ ev ] = cb; el.on(ev, cb); } }); return diff; }
this.__adapter.onDone((model) => { if (model.length) { /** * GET Collection case */ model.forEach((item) => { models.push( new Model(type, item.id, item, this.__adapter) ); }); p.resolve(models); } else { /** * GET Resource case */ this.attr = toCamel(clone(model, true)); storage.store(this); original[this.type + this.__unique] = model; p.resolve(this); } }).onFail(() => {
var chartSettings = map(bySeries.series, function(dataSeries, i) { var settings; // add data points to relevant scale scaleData = scaleData.concat(map(dataSeries.values, function(d) { return +d.value; })); if (chartProps.chartSettings[i]) { settings = chartProps.chartSettings[i]; } else { settings = clone(chartgrid_defaults.chartSettings[0]); settings.colorIndex = i; } if (parseOpts.columnsChanged) { settings.label = dataSeries.name; } else { settings.label = settings.label || dataSeries.name; } return settings; });
normalizeOptions(opts: Object) { opts = assign({}, opts); if (opts.filename) { var rcFilename = opts.filename; if (!isAbsolute(rcFilename)) rcFilename = path.join(process.cwd(), rcFilename); opts = resolveRc(rcFilename, opts); } // for (let key in opts) { if (key[0] === "_") continue; let option = File.options[key]; if (!option) this.log.error(`Unknown option: ${key}`, ReferenceError); } for (let key in File.options) { let option = File.options[key]; var val = opts[key]; if (!val && option.optional) continue; if (val && option.deprecated) { throw new Error("Deprecated option " + key + ": " + option.deprecated); } if (val == null) { val = clone(option.default); } var optionParser = optionParsers[option.type]; if (optionParser) val = optionParser(key, val, this.pipeline); if (option.alias) { opts[option.alias] = opts[option.alias] || val; } else { opts[key] = val; } } if (opts.inputSourceMap) { opts.sourceMaps = true; } // normalize windows path separators to unix opts.filename = slash(opts.filename); if (opts.sourceRoot) { opts.sourceRoot = slash(opts.sourceRoot); } if (opts.moduleId) { opts.moduleIds = true; } opts.basename = path.basename(opts.filename, path.extname(opts.filename)); opts.ignore = util.arrayify(opts.ignore, util.regexify); opts.only = util.arrayify(opts.only, util.regexify); defaults(opts, { moduleRoot: opts.sourceRoot }); defaults(opts, { sourceRoot: opts.moduleRoot }); defaults(opts, { filenameRelative: opts.filename }); defaults(opts, { sourceFileName: opts.filenameRelative, sourceMapName: opts.filenameRelative }); // if (opts.externalHelpers) { this.set("helpersNamespace", t.identifier("babelHelpers")); } return opts; };
normaliseOptions(opts: Object) { opts = this.opts = normaliseOptions(assign({}, opts)); // resolve babelrc if (opts.filename) { var rcFilename = opts.filename; if (!isAbsolute(rcFilename)) rcFilename = path.join(process.cwd(), rcFilename); opts = resolveRc(rcFilename, opts); } // check for unknown options for (let key in opts) { if (key[0] === "_") continue; let option = File.options[key]; if (!option) this.log.error(`Unknown option: ${key}`, ReferenceError); } // merge in environment options var envKey = process.env.BABEL_ENV || process.env.NODE_ENV || "development"; if (opts.env) merge(opts, normaliseOptions(opts.env[envKey])); // normalise options for (let key in File.options) { let option = File.options[key]; var val = opts[key]; // optional if (!val && option.optional) continue; // deprecated if (val && option.deprecated) { this.log.deprecate("Deprecated option " + key + ": " + option.deprecated); } // default if (val == null) val = clone(option.default); // validate if (val) val = validateOption(key, val, this.pipeline); // aaliases if (option.alias) { opts[option.alias] = opts[option.alias] || val; } else { opts[key] = val; } } if (opts.inputSourceMap) { opts.sourceMaps = true; } // normalize windows path separators to unix opts.filename = slash(opts.filename); if (opts.sourceRoot) { opts.sourceRoot = slash(opts.sourceRoot); } if (opts.moduleId) { opts.moduleIds = true; } opts.basename = path.basename(opts.filename, path.extname(opts.filename)); opts.ignore = util.arrayify(opts.ignore, util.regexify); if (opts.only) { opts.only = util.arrayify(opts.only, util.regexify); } defaults(opts, { moduleRoot: opts.sourceRoot }); defaults(opts, { sourceRoot: opts.moduleRoot }); defaults(opts, { filenameRelative: opts.filename }); defaults(opts, { sourceFileName: opts.filenameRelative, sourceMapTarget: opts.filenameRelative }); // if (opts.externalHelpers) { this.set("helpersNamespace", t.identifier("babelHelpers")); } return opts; };
var clone = require('lodash/lang/clone'); var partialObject = { objectID: 'dawg IE!', yaw: 'partial' }; module.exports = [{ object: 'index', methodName: 'partialUpdateObject', testName: 'index.partialUpdateObject(partialObject, cb)', callArguments: [partialObject], action: 'write', expectedRequest: { method: 'POST', body: clone(partialObject), URL: { pathname: '/1/indexes/%s/' + encodeURIComponent(partialObject.objectID) + '/partial' } } }, { object: 'index', methodName: 'partialUpdateObject', testName: 'index.partialUpdateObject(partialObject, createIfNotExists=false, cb)', callArguments: [partialObject, false], action: 'write', expectedRequest: { method: 'POST', body: clone(partialObject), URL: { pathname: '/1/indexes/%s/' + encodeURIComponent(partialObject.objectID) + '/partial',
return function (node) { if (node[bindingKey] === node[refKey]) { node[refKey] = t.removeComments(clone(node[refKey])); } };