How to use the object-assign function in object-assign

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 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 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;
      }
    });
  }
github react-paper / react-paper-bindings / demo / src / Paper / hoc / withHistory.js View on Github external
updateItem = (item, data) => {
      const history = this.getPrevHistory()
      const layerIndex = history.findIndex(l => l.id === item.layer.data.id)
      const children = history[layerIndex].children
      const itemIndex = children.findIndex(i => i.id === item.data.id)
      const nextItem = assign({}, children[itemIndex], data)
      const nextHistory = update(history, {
        [layerIndex]: { children: { [itemIndex]: { $set: nextItem } } }
      })
      this.addHistory(nextHistory)
      return nextItem
    }
github zkboys / www-nodejs-ant-design-web / assets / src / page / search-condition / SelectCascadedItem.jsx View on Github external
setNextOptions = (index, value)=> {
        let tempState = assign({}, this.state);
        let selects = tempState.selects;
        for (let i = 0; i < selects.length; i++) {
            if (i > index) {
                let item = selects[i - 1];
                let nextItem = selects[i];
                if (nextItem) {
                    let name = nextItem.name;
                    let options = [];
                    if(i-1===index){
                        options = item.getNextOptions && item.getNextOptions(value);
                    }
                    PubSubMsg.publish('setNextOptions' + name, {name, options})
                }
            }
        }
    };
github FineUploader / fine-uploader-wrappers / src / callback-proxy.js View on Github external
const executeThenableCallbacks = ({ registeredCallbacks, originalCallbackArguments }) => {
    if (registeredCallbacks.length) {
        return executeThenableCallback({
            registeredCallbacks: objectAssign([], registeredCallbacks).reverse(),
            originalCallbackArguments
        })
    }

    return Promise.resolve()
}

object-assign

ES2015 `Object.assign()` ponyfill

MIT
Latest version published 8 years ago

Package Health Score

77 / 100
Full package analysis