Skip to content

Commit

Permalink
assign -> Object.assign
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Oct 20, 2021
1 parent 4dc12c7 commit 291942e
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 38 deletions.
7 changes: 3 additions & 4 deletions packages/-ember-data/tests/integration/application-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Application from '@ember/application';
import Namespace from '@ember/application/namespace';
import Controller from '@ember/controller';
import { assign } from '@ember/polyfills';
import Service, { inject as service } from '@ember/service';

import { module, test } from 'qunit';
Expand All @@ -26,7 +25,7 @@ module('integration/application - Injecting a Custom Store', function (hooks) {
'controller:baz',
class Controller {
constructor(args) {
assign(this, args);
Object.assign(this, args);
}
@service('store') store;
static create(args) {
Expand Down Expand Up @@ -69,7 +68,7 @@ module('integration/application - Injecting the Default Store', function (hooks)
'controller:baz',
class Controller {
constructor(args) {
assign(this, args);
Object.assign(this, args);
}
@service('store') store;
static create(args) {
Expand Down Expand Up @@ -112,7 +111,7 @@ module('integration/application - Using the store as a service', function (hooks
'controller:baz',
class Controller {
constructor(args) {
assign(this, args);
Object.assign(this, args);
}
@service('store') store;
static create(args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { assign } from '@ember/polyfills';
import { run } from '@ember/runloop';

import { module, test } from 'qunit';
Expand Down Expand Up @@ -52,7 +51,7 @@ module('RecordData Compatibility', function (hooks) {
this.attributes = jsonApiResource.attributes || null;

if (shouldCalculateChanges) {
changedKeys = Object.keys(assign({}, oldAttrs, this.attributes));
changedKeys = Object.keys(Object.assign({}, oldAttrs, this.attributes));
}

return changedKeys || [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { assign } from '@ember/polyfills';
import { run } from '@ember/runloop';

import { module, test } from 'qunit';
Expand All @@ -9,7 +8,7 @@ import Store from '@ember-data/store';

class TestAdapter {
constructor(args) {
assign(this, args);
Object.assign(this, args);
this.didInit();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { assign } from '@ember/polyfills';
import { run } from '@ember/runloop';

import { module, test } from 'qunit';
Expand All @@ -10,7 +9,7 @@ import { deprecatedTest } from '@ember-data/unpublished-test-infra/test-support/

class TestAdapter {
constructor(args) {
assign(this, args);
Object.assign(this, args);
this.didInit();
}

Expand All @@ -23,7 +22,7 @@ class TestAdapter {

class TestSerializer {
constructor(args) {
assign(this, args);
Object.assign(this, args);
this.didInit();
}

Expand Down
3 changes: 1 addition & 2 deletions packages/-ember-data/tests/unit/store/peek-record-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import EmberObject from '@ember/object';
import { assign } from '@ember/polyfills';

import { module, test } from 'qunit';

Expand Down Expand Up @@ -113,7 +112,7 @@ module('unit/store/peekRecord - Store peekRecord', function (hooks) {
peekRecordArgs.lid = recordIdentifierFor(person).lid;
}
if (extra) {
assign(peekRecordArgs, extra);
Object.assign(peekRecordArgs, extra);
}

assert.strictEqual(
Expand Down
3 changes: 1 addition & 2 deletions packages/adapter/addon/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { getOwner } from '@ember/application';
import { assert, deprecate, warn } from '@ember/debug';
import { computed } from '@ember/object';
import { assign } from '@ember/polyfills';
import { join } from '@ember/runloop';
import { DEBUG } from '@glimmer/env';

Expand Down Expand Up @@ -1181,7 +1180,7 @@ class RESTAdapter extends Adapter.extend(BuildURLMixin) {
method: string,
options: JQueryAjaxSettings | RequestInit
): JQueryRequestInit | FetchRequestInit {
let reqOptions: JQueryRequestInit | FetchRequestInit = assign(
let reqOptions: JQueryRequestInit | FetchRequestInit = Object.assign(
{
url,
method,
Expand Down
4 changes: 1 addition & 3 deletions packages/canary-features/addon/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* globals EmberDataENV */

import { assign } from '@ember/polyfills';

import DEFAULT_FEATURES from './default-features';

type FeatureList = {
Expand All @@ -26,7 +24,7 @@ function featureValue(value: boolean | null): boolean | null {
return value;
}

export const FEATURES: FeatureList = assign({}, DEFAULT_FEATURES, ENV.FEATURES);
export const FEATURES: FeatureList = Object.assign({}, DEFAULT_FEATURES, ENV.FEATURES);
export const SAMPLE_FEATURE_FLAG = featureValue(FEATURES.SAMPLE_FEATURE_FLAG);
export const RECORD_DATA_ERRORS = featureValue(FEATURES.RECORD_DATA_ERRORS);
export const RECORD_DATA_STATE = featureValue(FEATURES.RECORD_DATA_STATE);
Expand Down
7 changes: 3 additions & 4 deletions packages/record-data/addon/-private/record-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* @module @ember-data/record-data
*/
import { assert } from '@ember/debug';
import { assign } from '@ember/polyfills';
import { _backburner as emberBackburner } from '@ember/runloop';
import { isEqual } from '@ember/utils';

Expand Down Expand Up @@ -98,7 +97,7 @@ export default class RecordDataDefault implements RelationshipRecordData {
changedKeys = this._changedKeys(data.attributes);
}

assign(this._data, data.attributes);
Object.assign(this._data, data.attributes);
if (this.__attributes) {
// only do if we have attribute changes
this._updateChangedAttributes();
Expand Down Expand Up @@ -305,7 +304,7 @@ export default class RecordDataDefault implements RelationshipRecordData {
}
let changedKeys = this._changedKeys(newCanonicalAttributes);

assign(this._data, this.__inFlightAttributes, newCanonicalAttributes);
Object.assign(this._data, this.__inFlightAttributes, newCanonicalAttributes);

this._inFlightAttributes = null;

Expand Down Expand Up @@ -752,7 +751,7 @@ export default class RecordDataDefault implements RelationshipRecordData {
attrs = this._attributes;
}

original = assign(Object.create(null), this._data, this.__inFlightAttributes);
original = Object.assign(Object.create(null), this._data, this.__inFlightAttributes);

for (i = 0; i < length; i++) {
key = keys[i];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { assign } from '@ember/polyfills';
import settled from '@ember/test-helpers/settled';

import { module, test as runTest } from 'qunit';
Expand Down Expand Up @@ -129,19 +128,19 @@ module('Integration | Graph | Edge Removal', function (hooks) {

TestScenarios.forEach(unpersistedDeletionTest);
TestScenarios.forEach((testConfig) => {
const config = assign({}, testConfig, { name: `[Newly Created] ${testConfig.name}`, useCreate: true });
const config = Object.assign({}, testConfig, { name: `[Newly Created] ${testConfig.name}`, useCreate: true });
unpersistedDeletionTest(config);
});
TestScenarios.forEach((testConfig) => {
const config = assign({}, testConfig, { name: `[LOCAL STATE] ${testConfig.name}`, dirtyLocal: true });
const config = Object.assign({}, testConfig, { name: `[LOCAL STATE] ${testConfig.name}`, dirtyLocal: true });
unpersistedDeletionTest(config);
});
});

module('Unload of a Record does not remove it from the graph', function () {
function unloadTest(_config: TestConfig) {
test(_config.name, async function (this: Context, assert) {
const config = assign({}, _config, { isUnloadAsDelete: true });
const config = Object.assign({}, _config, { isUnloadAsDelete: true });
const testState = await setInitialState(this, config, assert);
const { john } = testState;

Expand Down Expand Up @@ -185,11 +184,11 @@ module('Integration | Graph | Edge Removal', function (hooks) {

TestScenarios.forEach(unloadTest);
TestScenarios.forEach((testConfig) => {
const config = assign({}, testConfig, { name: `[Newly Created] ${testConfig.name}`, useCreate: true });
const config = Object.assign({}, testConfig, { name: `[Newly Created] ${testConfig.name}`, useCreate: true });
unloadTest(config);
});
TestScenarios.forEach((testConfig) => {
const config = assign({}, testConfig, { name: `[LOCAL STATE] ${testConfig.name}`, dirtyLocal: true });
const config = Object.assign({}, testConfig, { name: `[LOCAL STATE] ${testConfig.name}`, dirtyLocal: true });
unloadTest(config);
});
});
Expand Down Expand Up @@ -231,11 +230,11 @@ module('Integration | Graph | Edge Removal', function (hooks) {

TestScenarios.forEach(persistedDeletionTest);
TestScenarios.forEach((testConfig) => {
const config = assign({}, testConfig, { name: `[Newly Created] ${testConfig.name}`, useCreate: true });
const config = Object.assign({}, testConfig, { name: `[Newly Created] ${testConfig.name}`, useCreate: true });
persistedDeletionTest(config);
});
TestScenarios.forEach((testConfig) => {
const config = assign({}, testConfig, { name: `[LOCAL STATE] ${testConfig.name}`, dirtyLocal: true });
const config = Object.assign({}, testConfig, { name: `[LOCAL STATE] ${testConfig.name}`, dirtyLocal: true });
persistedDeletionTest(config);
});
});
Expand All @@ -259,11 +258,11 @@ module('Integration | Graph | Edge Removal', function (hooks) {

TestScenarios.forEach(persistedDeletionUnloadedTest);
TestScenarios.forEach((testConfig) => {
const config = assign({}, testConfig, { name: `[Newly Created] ${testConfig.name}`, useCreate: true });
const config = Object.assign({}, testConfig, { name: `[Newly Created] ${testConfig.name}`, useCreate: true });
persistedDeletionUnloadedTest(config);
});
TestScenarios.forEach((testConfig) => {
const config = assign({}, testConfig, { name: `[LOCAL STATE] ${testConfig.name}`, dirtyLocal: true });
const config = Object.assign({}, testConfig, { name: `[LOCAL STATE] ${testConfig.name}`, dirtyLocal: true });
persistedDeletionUnloadedTest(config);
});
});
Expand Down
3 changes: 1 addition & 2 deletions packages/serializer/addon/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { getOwner } from '@ember/application';
import { assert, warn } from '@ember/debug';
import { get } from '@ember/object';
import { assign } from '@ember/polyfills';
import { isNone, typeOf } from '@ember/utils';

import Serializer from '@ember-data/serializer';
Expand Down Expand Up @@ -1155,7 +1154,7 @@ const JSONSerializer = Serializer.extend({
@param {Object} options
*/
serializeIntoHash(hash, typeClass, snapshot, options) {
assign(hash, this.serialize(snapshot, options));
Object.assign(hash, this.serialize(snapshot, options));
},

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { assign } from '@ember/polyfills';

// publicProps(['prop1', 'prop2'], { prop1: val, prop2: val2, privatePro: val3 }) -> { prop1: val, prop2: val2 }
export default function publicProps(publicArgs, obj) {
return assign.apply(
return Object.assign.apply(
this,
[{}].concat(
Object.keys(obj).map((key) => ({
[key]: assign.apply(this, [{}].concat(publicArgs.map((prop) => ({ [prop]: obj[key][prop] })))),
[key]: Object.assign.apply(this, [{}].concat(publicArgs.map((prop) => ({ [prop]: obj[key][prop] })))),
}))
)
);
Expand Down

0 comments on commit 291942e

Please sign in to comment.