How to use extend - 10 common examples

To help you get started, we’ve selected a few extend 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 SpoonX / aurelia-api / dist / aurelia-api.js View on Github external
request(method: string, path: string, body?: {}, options?: {}, responseOutput?: { response: Response}): Promise {
    let requestOptions = extend(true, {headers: {}}, this.defaults || {}, options || {}, {method, body});
    let contentType    = requestOptions.headers['Content-Type'] || requestOptions.headers['content-type'];

    // if body is object, stringify to json or urlencoded depending on content-type
    if (typeof body === 'object' && body !== null && contentType) {
      requestOptions.body = (/^application\/(.+\+)?json/).test(contentType.toLowerCase())
                          ? JSON.stringify(body)
                          : buildQueryString(body);
    }

    return this.client.fetch(path, requestOptions).then((response: Response) => {
      if (response.status >= 200 && response.status < 400) {
        if (responseOutput) {
          responseOutput.response = response;
        }

        return response.json().catch(() => null);
github duojs / duo / lib / duo.js View on Github external
var gh = parse(dep);

  // We have all the information we need from `dep`.
  // Set the `package` key and return.
  if (gh.user && gh.repo && gh.ref) {
    gh.package = gh.user + '/' + gh.repo;
    return gh;
  }

  var dev = this.development();
  var deps = manifest.dependencies || {};
  var rext = /([\.][a-z]+)?/;

  // Include development dependencies if `development(true)` is set.
  if (dev && manifest === this.json) {
    deps = extend(deps, manifest.development || {});
  }

  // Build a regexp based on if we have the `user` key or not.
  // If we have the `user` key, our search is more specific.
  var re = gh.user
    ? new RegExp('^' + gh.user + '[\\/:]' + gh.repo + rext.source + '$', 'i')
    : new RegExp('([\\/:])' + gh.repo + rext.source + '$', 'i');

  // Not enough information yet.
  // Search through the manifest for our dependency.
  for (dep in deps) {
    if (re.test(dep) || dep.replace('/', '-') === gh.repo) {
      gh.package = dep;
      gh.ref = deps[dep];
      return gh;
    }
github qlik-oss / picasso.js / packages / picasso.js / src / core / chart-components / grid / line.js View on Github external
render() {
    // Setup scales
    this.x = this.settings.x ? this.chart.scale(this.settings.x) : null;
    this.y = this.settings.y ? this.chart.scale(this.settings.y) : null;
    updateScaleSize(this, 'x', this.rect.width);
    updateScaleSize(this, 'y', this.rect.height);

    // Return an empty array to abort rendering when no scales are available to renderer
    if (!this.x && !this.y) {
      return [];
    }

    this.settings.ticks = extend({ show: true }, this.style.ticks, this.settings.ticks || {});
    this.settings.minorTicks = extend({ show: false }, this.style.minorTicks, this.settings.minorTicks || {});

    // Setup lines for X and Y
    this.lines = {
      x: [],
      y: []
    };

    // Use the lineGen function to generate appropriate ticks
    this.lines.x = lineGen(this.x, this.rect.width);
    this.lines.y = lineGen(this.y, this.rect.height);

    // Set all Y lines to flipXY by default
    // This makes the transposer flip them individually
    this.lines.y = this.lines.y.map((i) => extend(i, { flipXY: true }));
github superhighfives / react-three-playground / src / playgrounds / 06.js View on Github external
// Grab a video, make it a texture
    this.videoTexture = new Texture(this.video)
    this.videoTexture.minFilter = LinearFilter
    this.videoTexture.magFilter = LinearFilter

    this.shaderManager = new ShaderManager(this.videoTexture)
    this.shaderManager.add(GreyscaleShader)
    this.shaderManager.add(DotsShader)
    this.shaderManager.add(TVShader)

    // Use rendered scene as a material
    // And something to cast shadows onto
    const planeSize = this.getGeometrySize()
    const planeGeometry = new PlaneGeometry(planeSize, planeSize, 1, 1)
    this.uniforms = extend(TextureShader.uniforms, {
      texture: {type: 't', value: this.shaderManager.texture()},
      resolution: {type: 'v2', value: new Vector2(window.innerWidth, window.innerHeight)},
      time: {type: 'f', value: 0.0}
    })
    this.planeMaterial = new ShaderMaterial({
      vertexShader: TextureShader.vertexShader,
      fragmentShader: TextureShader.fragmentShader,
      uniforms: this.uniforms
    })
    this.plane = new Mesh(planeGeometry, this.planeMaterial)
    this.scene.add(this.plane)

    // Resize things when the window resizes
    window.addEventListener('resize', this.onResize.bind(this))
  }
  getOrthographicSizes () {
github avcs06 / SVGPanZoom / es / SVGPanZoom.js View on Github external
set initialViewBox(value) {
                    // Set initial viewbox
                    if (value !== null) {
                        if (typeof value === "string") {
                            viewBox = parseViewBoxString(value);
                        } else if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === "object") {
                            viewBox = extend({}, defaultViewBox, value);
                        } else {
                            throw new Error('initialViewBox is of invalid type');
                        }
                    }

                    _initialViewBox = extend({}, viewBox);
                },
                get animationTime() {
github Monadical-SAS / redux-time / es6 / util.js View on Github external
throw 'Patch paths must not have trailing slashes or empty keys!'
    }
    let parent = obj
    for (let key of keys) {
        // create path if any point is missing
        if ((mkpath && (parent[key] === undefined || parent[key] === null)) || isBaseType(parent[key], false)) {
            parent[key] = {}
        }
        parent = parent[key]
    }
    if (merge) {
        parent[last_key] = deepMerge(parent[last_key], new_val)
    } else {
        parent[last_key] = new_val
    }
    return deepcopy ? extend(true, {}, obj) : obj
}
github qlik-oss / picasso.js / packages / picasso.js / src / core / scene-graph / display-objects / container.js View on Github external
removeChild(c) {
    c._stage = null;
    let desc = c.descendants,
      num = desc ? desc.length : 0,
      i;
    // remove reference to stage from all descendants
    for (i = 0; i < num; i++) {
      desc[i]._stage = null;
    }

    NC.removeChild.call(this, c);

    if (this._collider && this._collider.type === 'bounds') {
      this.__boundingRect = { true: null, false: null };
      this.__bounds = { true: null, false: null };
      const opts = extend(this.boundingRect(true), { type: 'bounds' });
      this.collider = opts;
    }

    return this;
  }
github ractivejs / ractive / src / extend / inheritFromParent.js View on Github external
registries.filter( property => {
		return newreg.keys.indexOf( property ) === -1
	}).forEach( property => {

		if ( Parent[ property ] ) {
			Child[ property ] = create( Parent[ property ] );
		}

	});

	// Special case - CSS
	if ( Parent.css ) {
		defineProperty( Child, 'css', {
			value: Parent.defaults.noCssTransform
				? Parent.css
				: transformCss( Parent.css, Child._guid )
		});
	}
}
github ractivejs / ractive / src / config / configuration.js View on Github external
todo_data( Parent, Child, options.data );

		config.forEach( each => {
			each.extend( Parent, Child, options ) }
		);

		for ( let key in options ) {

			if ( !blacklisted[ key ] && options.hasOwnProperty( key ) ) {

				let member = options[ key ]

				// if this is a method that overwrites a method, wrap it:
				if ( typeof member === 'function' ) {
					member = wrapMethod( member, Child.prototype[ key ] );
				}

				Child.prototype[ key ] = member;

			}
		}
	},
github googleapis / nodejs-error-reporting / test / unit / request-extractors / express.ts View on Github external
const headerFactory = (toDeriveFrom: any) => {
      const lrn = extend({}, toDeriveFrom);
      lrn.header = (toRet: string) => {
        if (lrn.hasOwnProperty(toRet)) {
          return lrn[toRet];
        }
        return undefined;
      };
      return lrn;
    };
    let tmpOutput = expressRequestInformationExtractor(

extend

Port of jQuery.extend for node.js and the browser

MIT
Latest version published 6 years ago

Package Health Score

74 / 100
Full package analysis