How to use object-assign - 10 common examples

To help you get started, we’ve selected a few object-assign 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 Jam3 / detect-import-require / test / fixtures / module.js View on Github external
var path = require('path')
var foo1 = require('object-assign')
var another = require('object-assign').another
import { foo } from './foo'
import { foo as blah } from './blah'
import * as _ from 'lodash'
import defs from 'defaults'
import 'side-effects'
// import 'commented'
/* import { foo } from 'commented2'; */
// require('commented3')
require(__dirname + '/file.js')
require(path.join(__dirname, '/file.js'))

export default function () {
  var b = require('b')
}
github trendmicro-frontend / react-datepicker / src / DatePickerSrc / HistoryView.js View on Github external
const yearViewChildProps = yearViewChild ? yearViewChild.props : {};

        const tabIndex = yearViewChildProps.tabIndex == null ?
            null
            :
            yearViewChildProps.tabIndex;

        yearViewProps.tabIndex = tabIndex;

        if (props.focusYearView === false || tabIndex == null) {
            yearViewProps.tabIndex = null;
            yearViewProps.onFocus = this.onYearViewFocus;
            yearViewProps.onMouseDown = this.onYearViewMouseDown;
        }

        assign(yearViewProps, {
            // viewDate: props.moment || props.viewDate,
            onViewDateChange: joinFunctions(
                this.onViewDateChange,
                yearViewChildProps.onViewDateChange
            ),
            onActiveDateChange: joinFunctions(
                this.onActiveDateChange,
                yearViewChildProps.onActiveDateChange
            ),
            onChange: joinFunctions(
                this.handleYearViewOnChange,
                yearViewChildProps.onChange
            )
        });

        if (yearViewChild) {
github nthiebes / booky.io / _source / reducers / fuelSavingsReducer.js View on Github external
export default function fuelSavingsReducer(state = initialState.fuelSavings, action) {
  let newState;

  switch (action.type) {
    case SAVE_FUEL_SAVINGS:
      // For this example, just simulating a save by changing date modified.
      // In a real app using Redux, you might use redux-thunk and handle the async call in fuelSavingsActions.js
      return objectAssign({}, state, {dateModified: action.dateModified});

    case CALCULATE_FUEL_SAVINGS:
      newState = objectAssign({}, state);
      newState[action.fieldName] = action.value;
      newState.necessaryDataIsProvidedToCalculateSavings = calculator().necessaryDataIsProvidedToCalculateSavings(newState);
      newState.dateModified = action.dateModified;

      if (newState.necessaryDataIsProvidedToCalculateSavings) {
        newState.savings = calculator().calculateSavings(newState);
      }

      return newState;

    default:
      return state;
  }
}
github YR / component / index.js View on Github external
var comp = function (_Component) {
      babelHelpers.inherits(comp, _Component);

      function comp() {
        babelHelpers.classCallCheck(this, comp);
        return babelHelpers.possibleConstructorReturn(this, _Component.apply(this, arguments));
      }

      return comp;
    }(Component);

    // Handle mixins
    if (mixins && mixins.length) {
      // Merge/clone
      mixins = assign.apply(undefined, [{}].concat(mixins));
      // Store method names to autobind on instantiation
      specification.__bindableMethods = Object.keys(mixins).filter(function (key) {
        return !~RESERVED_METHODS.indexOf(key) && 'function' == typeof mixins[key];
      });
      specification = assign(specification, mixins);
    }
    comp.displayName = specification.displayName || '';
    delete specification.displayName;

    // Rename select keys to prevent overwriting
    proxyKeys(specification, PROXY_KEYS);
    // Copy to comp prototype
    assign(comp.prototype, specification);

    return function createElement(props) {
      processProps(props, specification);
github firejune / electron-react-devtools / src / frontend / Panel.js View on Github external
// properly doing so probably requires refactoring how we load the panel
      // and communicate with the bridge.
      return (
        <div style="{loadingStyle(theme)}">
          <h2>Connecting to React…</h2>
        </div>
      );
    }
    if (!this.state.isReact) {
      return (
        <div style="{loadingStyle(theme)}">
          <h2>Looking for React…</h2>
        </div>
      );
    }
    var extraTabs = assign.apply(null, [{}].concat(this.plugins.map(p =&gt; p.tabs())));
    var extraPanes = [].concat(...this.plugins.map(p =&gt; p.panes()));
    if (this._store.capabilities.rnStyle) {
      extraPanes.push(panelRNStyle(this._bridge, this._store.capabilities.rnStyleMeasure, theme));
    }
    return (
       {
            if (!val || node.get('nodeType') !== 'Composite' || val[consts.type] !== 'function') {
              return undefined;
            }
            return [this.props.showAttrSource &amp;&amp; {
              key: 'showSource',
              title: 'Show function source',
github translate / pootle / pootle / static / js / captcha.js View on Github external
function onSubmit(e) {
  e.preventDefault();
  const $form = $(this);
  const reqData = assign(PTL.captcha.postData, $form.serializeObject());
  const successFn = reqData.sfn;
  const errorFn = reqData.efn;
  const url = $form.attr('action');

  $.ajax({
    url,
    type: 'POST',
    data: reqData,
    success() {
      utils.executeFunctionByName(successFn, window, e);
      $.magnificPopup.close();
    },
    error(xhr) {
      onError(xhr, errorFn);
    },
  });
github wevote / WeVoteServer / web_app / src / utils / createStore.js View on Github external
export function createStore(mixin) {
    const store = assign({}, EventEmitter.prototype, {
        emitChange() {
            this.emit(CHANGE_EVENT);
        },

        addChangeListener(callback) {
            this.on(CHANGE_EVENT, callback);
        },

        removeChangeListener(callback) {
            this.removeChangeListener(CHANGE_EVENT, callback);
        }

    }, mixin);

    return store;
}
github weiq / antui-admin / src / components / form / DateForm.js View on Github external
Component = MonthPicker;
      break;
    case 'time':
      Component = TimePicker;
      break;
  }

  let _format = "";

  if (format) _format = format;
  else if (type === 'datetime' || type === 'date~') _format = "YYYY-MM-DD HH:mm:ss";
  else if (type === 'time') _format = "HH:mm:ss";
  else _format = "YYYY-MM-DD";

  return getFieldDecorator(name, formFieldOptions)(
    
  );
};
github trendmicro-frontend / react-datepicker / src / DatePickerSrc / DateField / index.js View on Github external
onChange(dateMoment) {
        if (dateMoment != null && !moment.isMoment(dateMoment)) {
            dateMoment = this.toMoment(dateMoment);
        }

        forwardTime(this.time, dateMoment);

        const newState = {};

        if (this.props.value === undefined) {
            assign(newState, {
                text: null,
                value: dateMoment
            });
        }

        newState.activeDate = dateMoment;

        if (!this.pickerView || !this.pickerView.isInView || !this.pickerView.isInView(dateMoment)) {
            newState.viewDate = dateMoment;
        }

        if (this.props.onChange) {
            this.props.onChange(this.format(dateMoment), { dateMoment });
        }

        this.setState(newState);
github micnews / article-json-to-apple-news / lib / index.js View on Github external
const bundlesToUrls = bundleImages(components);
  const article = {
    version: '1.0',
    identifier: opts.identifier,
    title: articleJson.title,
    language: articleJson.language || 'en',
    metadata: {
      generatorName: 'article-json-to-apple-news',
      generatorVersion: packageJson.version
    },
    documentStyle: opts.documentStyle,
    layout: objectAssign({}, defaultStyles.layout, opts.layout),
    componentLayouts: objectAssign({}, defaultStyles.componentLayouts, opts.componentLayouts),
    componentTextStyles: objectAssign({}, defaultStyles.componentTextStyles, opts.componentTextStyles),
    componentStyles: objectAssign({}, defaultStyles.componentStyles, opts.componentStyles),
    textStyles: objectAssign({}, defaultStyles.textStyles, opts.textStyles),
    components
  };

  if (articleJson.author && articleJson.author.name) {
    article.metadata.authors = [articleJson.author.name];
  }

  if (articleJson.headerEmbed && articleJson.headerEmbed.type === 'embed' &&
      articleJson.headerEmbed.embedType === 'image') {
    Object.keys(bundlesToUrls).forEach(function (key) {
      const value = bundlesToUrls[key];
      if (value === articleJson.headerEmbed.src) {
        article.metadata.thumbnailURL = 'bundle://' + key;
      }
    });
  }

object-assign

ES2015 `Object.assign()` ponyfill

MIT
Latest version published 8 years ago

Package Health Score

77 / 100
Full package analysis