Skip to content

Commit

Permalink
Update imports with codemod
Browse files Browse the repository at this point in the history
  • Loading branch information
locks committed Jul 31, 2017
1 parent 87b7652 commit 5cef8a1
Show file tree
Hide file tree
Showing 160 changed files with 1,109 additions and 1,102 deletions.
9 changes: 5 additions & 4 deletions addon/-private/adapters/build-url-mixin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { camelize } from '@ember/string';
import Mixin from '@ember/object/mixin';
import { get } from '@ember/object';
import Ember from 'ember';

const get = Ember.get;

/**
WARNING: This interface is likely to change in order to accomodate https://github.com/emberjs/rfcs/pull/4
Expand Down Expand Up @@ -29,7 +30,7 @@ const get = Ember.get;
@class BuildURLMixin
@namespace DS
*/
export default Ember.Mixin.create({
export default Mixin.create({
/**
Builds a URL for a given type and optional ID.
Expand Down Expand Up @@ -434,7 +435,7 @@ export default Ember.Mixin.create({
@return {String} path
**/
pathForType(modelName) {
let camelized = Ember.String.camelize(modelName);
let camelized = camelize(modelName);
return Ember.String.pluralize(camelized);
}
});
12 changes: 6 additions & 6 deletions addon/-private/adapters/errors.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Ember from 'ember';
import { makeArray } from '@ember/array';
import { isPresent } from '@ember/utils';
import EmberError from '@ember/error';
import { assert } from '@ember/debug';

import isEnabled from '../features';

const EmberError = Ember.Error;

const SOURCE_POINTER_REGEXP = /^\/?data\/(attributes|relationships)\/(.*)/;
const SOURCE_POINTER_PRIMARY_REGEXP = /^\/?data/;
const PRIMARY_ATTRIBUTE_KEY = 'base';
Expand Down Expand Up @@ -388,9 +388,9 @@ export const ServerError = extendedErrorsEnabled ?
export function errorsHashToArray(errors) {
let out = [];

if (Ember.isPresent(errors)) {
if (isPresent(errors)) {
Object.keys(errors).forEach((key) => {
let messages = Ember.makeArray(errors[key]);
let messages = makeArray(errors[key]);
for (let i = 0; i < messages.length; i++) {
let title = 'Invalid Attribute';
let pointer = `/data/attributes/${key}`;
Expand Down Expand Up @@ -455,7 +455,7 @@ export function errorsHashToArray(errors) {
export function errorsArrayToHash(errors) {
let out = {};

if (Ember.isPresent(errors)) {
if (isPresent(errors)) {
errors.forEach((error) => {
if (error.source && error.source.pointer) {
let key = error.source.pointer.match(SOURCE_POINTER_REGEXP);
Expand Down
23 changes: 13 additions & 10 deletions addon/-private/system/debug/debug-adapter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/**
@module ember-data
*/
import Ember from 'ember';
import { addObserver, removeObserver } from '@ember/object/observers';

import { A } from '@ember/array';
import DataAdapter from '@ember/debug/data-adapter';
import { capitalize, underscore } from '@ember/string';
import { assert } from '@ember/debug';
import { get } from '@ember/object';
import Model from '../model/model';
const capitalize = Ember.String.capitalize;
const underscore = Ember.String.underscore;
const { assert, get } = Ember;

/*
Extend `Ember.DataAdapter` with ED specific code.
Expand All @@ -15,7 +18,7 @@ const { assert, get } = Ember;
@extends Ember.DataAdapter
@private
*/
export default Ember.DataAdapter.extend({
export default DataAdapter.extend({
getFilters() {
return [
{ name: 'isNew', desc: 'New' },
Expand Down Expand Up @@ -73,7 +76,7 @@ export default Ember.DataAdapter.extend({

getRecordKeywords(record) {
let keywords = [];
let keys = Ember.A(['id']);
let keys = A(['id']);
record.eachAttribute((key) => keys.push(key));
keys.forEach((key) => keywords.push(get(record, key)));
return keywords;
Expand All @@ -98,8 +101,8 @@ export default Ember.DataAdapter.extend({
},

observeRecord(record, recordUpdated) {
let releaseMethods = Ember.A();
let keysToObserve = Ember.A(['id', 'isNew', 'hasDirtyAttributes']);
let releaseMethods = A();
let keysToObserve = A(['id', 'isNew', 'hasDirtyAttributes']);

record.eachAttribute((key) => keysToObserve.push(key));
let adapter = this;
Expand All @@ -108,9 +111,9 @@ export default Ember.DataAdapter.extend({
let handler = function() {
recordUpdated(adapter.wrapRecord(record));
};
Ember.addObserver(record, key, handler);
addObserver(record, key, handler);
releaseMethods.push(function() {
Ember.removeObserver(record, key, handler);
removeObserver(record, key, handler);
});
});

Expand Down
7 changes: 4 additions & 3 deletions addon/-private/system/is-array-like.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import { typeOf } from '@ember/utils';
import EmberArray from '@ember/array';

/*
We're using this to detect arrays and "array-like" objects.
Expand All @@ -13,9 +14,9 @@ import Ember from 'ember';
export default function isArrayLike(obj) {
if (!obj || obj.setInterval) { return false; }
if (Array.isArray(obj)) { return true; }
if (Ember.Array.detect(obj)) { return true; }
if (EmberArray.detect(obj)) { return true; }

let type = Ember.typeOf(obj);
let type = typeOf(obj);
if ('array' === type) { return true; }
if ((obj.length !== undefined) && 'object' === type) { return true; }
return false;
Expand Down
12 changes: 7 additions & 5 deletions addon/-private/system/many-array.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/**
@module ember-data
*/
import Ember from 'ember';
import { all } from 'rsvp';

import Evented from '@ember/object/evented';
import MutableArray from '@ember/array/mutable';
import EmberObject, { get } from '@ember/object';
import { assert } from '@ember/debug';
import { PromiseArray } from "./promise-proxies";
import { _objectIsAlive } from "./store/common";
import diffArray from './diff-array';

const { get } = Ember;

/**
A `ManyArray` is a `MutableArray` that represents the contents of a has-many
relationship.
Expand Down Expand Up @@ -52,7 +54,7 @@ const { get } = Ember;
@extends Ember.Object
@uses Ember.MutableArray, Ember.Evented
*/
export default Ember.Object.extend(Ember.MutableArray, Ember.Evented, {
export default EmberObject.extend(MutableArray, Evented, {
init() {
this._super(...arguments);

Expand Down Expand Up @@ -260,7 +262,7 @@ export default Ember.Object.extend(Ember.MutableArray, Ember.Evented, {
save() {
let manyArray = this;
let promiseLabel = 'DS: ManyArray#save ' + get(this, 'type');
let promise = Ember.RSVP.all(this.invoke("save"), promiseLabel).
let promise = all(this.invoke("save"), promiseLabel).
then(() => manyArray, null, 'DS: ManyArray#save return ManyArray');

return PromiseArray.create({ promise });
Expand Down
28 changes: 16 additions & 12 deletions addon/-private/system/model/errors.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import Ember from 'ember';
import { mapBy, not } from '@ember/object/computed';
import Evented from '@ember/object/evented';
import ArrayProxy from '@ember/array/proxy';
import { set, get, computed } from '@ember/object';
import { isEmpty } from '@ember/utils';
import { makeArray, A } from '@ember/array';
import MapWithDefault from '@ember/map/with-default';
import { deprecate, warn } from '@ember/debug';

const { get, set, isEmpty, makeArray, MapWithDefault } = Ember;

/**
@module ember-data
*/
Expand Down Expand Up @@ -82,7 +86,7 @@ const { get, set, isEmpty, makeArray, MapWithDefault } = Ember;
@uses Ember.Enumerable
@uses Ember.Evented
*/
export default Ember.ArrayProxy.extend(Ember.Evented, {
export default ArrayProxy.extend(Evented, {
/**
Register with target handler
Expand Down Expand Up @@ -120,10 +124,10 @@ export default Ember.ArrayProxy.extend(Ember.Evented, {
@type {Ember.MapWithDefault}
@private
*/
errorsByAttributeName: Ember.computed(function() {
errorsByAttributeName: computed(function() {
return MapWithDefault.create({
defaultValue() {
return Ember.A();
return A();
}
});
}),
Expand Down Expand Up @@ -165,15 +169,15 @@ export default Ember.ArrayProxy.extend(Ember.Evented, {
@property messages
@type {Array}
*/
messages: Ember.computed.mapBy('content', 'message'),
messages: mapBy('content', 'message'),

/**
@property content
@type {Array}
@private
*/
content: Ember.computed(function() {
return Ember.A();
content: computed(function() {
return A();
}),

/**
Expand All @@ -199,7 +203,7 @@ export default Ember.ArrayProxy.extend(Ember.Evented, {
@type {Boolean}
@readOnly
*/
isEmpty: Ember.computed.not('length').readOnly(),
isEmpty: not('length').readOnly(),

/**
Adds error messages to a given attribute and sends
Expand Down Expand Up @@ -383,7 +387,7 @@ export default Ember.ArrayProxy.extend(Ember.Evented, {
if (get(this, 'isEmpty')) { return; }

let errorsByAttributeName = get(this, 'errorsByAttributeName');
let attributes = Ember.A();
let attributes = A();

errorsByAttributeName.forEach(function(_, attribute) {
attributes.push(attribute);
Expand All @@ -394,7 +398,7 @@ export default Ember.ArrayProxy.extend(Ember.Evented, {
this.notifyPropertyChange(attribute);
}, this);

Ember.ArrayProxy.prototype.clear.call(this);
ArrayProxy.prototype.clear.call(this);
},


Expand Down
36 changes: 15 additions & 21 deletions addon/-private/system/model/internal-model.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { assign as emberAssign, merge } from '@ember/polyfills';
import { set, get } from '@ember/object';
import { copy } from '@ember/object/internals';
import EmberError from '@ember/error';
import { isEqual, isEmpty } from '@ember/utils';
import { setOwner } from '@ember/application';
import { run } from '@ember/runloop';
import RSVP, { Promise } from 'rsvp';
import Ember from 'ember';
import { DEBUG } from '@glimmer/env';
import { assert } from '@ember/debug';
import { assert, inspect } from '@ember/debug';
import RootState from "./states";
import Relationships from "../relationships/state/create";
import Snapshot from "../snapshot";
Expand All @@ -15,32 +23,18 @@ import {
HasManyReference
} from "../references";

const {
get,
set,
copy,
Error: EmberError,
inspect,
isEmpty,
isEqual,
setOwner,
run,
RSVP,
RSVP: { Promise }
} = Ember;

const assign = Ember.assign || Ember.merge;
const assign = emberAssign || merge;

/*
The TransitionChainMap caches the `state.enters`, `state.setups`, and final state reached
when transitioning from one state to another, so that future transitions can replay the
transition without needing to walk the state tree, collect these hook calls and determine
the state to transition into.
the state to transition into.
A future optimization would be to build a single chained method out of the collected enters
and setups. It may also be faster to do a two level cache (from: { to }) instead of caching based
on a key that adds the two together.
*/
A future optimization would be to build a single chained method out of the collected enters
and setups. It may also be faster to do a two level cache (from: { to }) instead of caching based
on a key that adds the two together.
*/
const TransitionChainMap = Object.create(null);

const _extractPivotNameCache = Object.create(null);
Expand Down
Loading

0 comments on commit 5cef8a1

Please sign in to comment.