Skip to content

Commit

Permalink
[CLEANUP Beta] Remove ArrayPolyfils – ES5 only support now
Browse files Browse the repository at this point in the history
(╯°□°)╯︵  sʃʃıɟʎʃod¬ ʎɐɹɹɐ¬
  • Loading branch information
stefanpenner committed Jun 15, 2015
1 parent 0d0b16a commit 62916e8
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 212 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import run from "ember-metal/run_loop";
import { forEach } from "ember-metal/array";
import Application from "ember-application/system/application";

var application, registry;
Expand Down Expand Up @@ -38,7 +37,7 @@ QUnit.test('normalization', function() {
QUnit.test('normalization is indempotent', function() {
var examples = ['controller:posts', 'controller:posts.post.index', 'controller:blog/posts.post_index', 'template:foo_bar'];

forEach.call(examples, function (example) {
examples.forEach((example) => {
equal(registry.normalize(registry.normalize(example)), registry.normalize(example));
});
});
9 changes: 4 additions & 5 deletions packages/ember-application/tests/system/initializers_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import isEnabled from "ember-metal/features";
import run from "ember-metal/run_loop";
import Application from "ember-application/system/application";
import { indexOf } from "ember-metal/array";
import jQuery from "ember-views/system/jquery";
import Registry from "container/registry";

Expand Down Expand Up @@ -228,10 +227,10 @@ QUnit.test("initializers can have multiple dependencies", function () {
});
});

ok(indexOf.call(order, a.name) < indexOf.call(order, b.name), 'a < b');
ok(indexOf.call(order, b.name) < indexOf.call(order, c.name), 'b < c');
ok(indexOf.call(order, b.name) < indexOf.call(order, afterB.name), 'b < afterB');
ok(indexOf.call(order, c.name) < indexOf.call(order, afterC.name), 'c < afterC');
ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b');
ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c');
ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB');
ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC');
});

QUnit.test("initializers set on Application subclasses should not be shared between apps", function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import isEnabled from "ember-metal/features";
import run from "ember-metal/run_loop";
import Application from "ember-application/system/application";
import ApplicationInstance from "ember-application/system/application-instance";
import { indexOf } from "ember-metal/array";
import jQuery from "ember-views/system/jquery";

var app, initializeContextFeatureEnabled;
Expand Down Expand Up @@ -232,10 +231,10 @@ if (isEnabled('ember-application-instance-initializers')) {
});
});

ok(indexOf.call(order, a.name) < indexOf.call(order, b.name), 'a < b');
ok(indexOf.call(order, b.name) < indexOf.call(order, c.name), 'b < c');
ok(indexOf.call(order, b.name) < indexOf.call(order, afterB.name), 'b < afterB');
ok(indexOf.call(order, c.name) < indexOf.call(order, afterC.name), 'c < afterC');
ok(order.indexOf(a.name) < order.indexOf(b.name), 'a < b');
ok(order.indexOf(b.name) < order.indexOf(c.name), 'b < c');
ok(order.indexOf(b.name) < order.indexOf(afterB.name), 'b < afterB');
ok(order.indexOf(c.name) < order.indexOf(afterC.name), 'c < afterC');
});

QUnit.test("initializers set on Application subclasses should not be shared between apps", function() {
Expand Down
135 changes: 0 additions & 135 deletions packages/ember-metal/lib/array.js

This file was deleted.

5 changes: 1 addition & 4 deletions packages/ember-metal/lib/chains.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Ember from "ember-metal/core"; // warn, assert, etc;
import { get, normalizeTuple } from "ember-metal/property_get";
import { meta as metaFor } from "ember-metal/utils";
import { forEach } from "ember-metal/array";
import { watchKey, unwatchKey } from "ember-metal/watch_key";

var warn = Ember.warn;
Expand Down Expand Up @@ -32,9 +31,7 @@ export function flushPendingChains() {
var queue = pendingQueue;
pendingQueue = [];

forEach.call(queue, (q) => {
q[0].add(q[1]);
});
queue.forEach((q) => q[0].add(q[1]));

warn('Watching an undefined global, Ember expects watched globals to be' +
' setup by the time the run loop is flushed, check for typos', pendingQueue.length === 0);
Expand Down
9 changes: 4 additions & 5 deletions packages/ember-metal/lib/expand_properties.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import EmberError from 'ember-metal/error';
import { forEach } from 'ember-metal/array';

/**
@module ember
Expand Down Expand Up @@ -43,13 +42,13 @@ export default function expandProperties(pattern, callback) {
var parts = pattern.split(SPLIT_REGEX);
var properties = [parts];

forEach.call(parts, function(part, index) {
parts.forEach((part, index) => {
if (part.indexOf(',') >= 0) {
properties = duplicateAndReplace(properties, part.split(','), index);
}
});

forEach.call(properties, function(property) {
properties.forEach((property) => {
callback(property.join(''));
});
} else {
Expand All @@ -60,8 +59,8 @@ export default function expandProperties(pattern, callback) {
function duplicateAndReplace(properties, currentParts, index) {
var all = [];

forEach.call(properties, (property) => {
forEach.call(currentParts, (part) => {
properties.forEach((property) => {
currentParts.forEach((part) => {
var current = property.slice(0);
current[index] = part;
all.push(current);
Expand Down
13 changes: 0 additions & 13 deletions packages/ember-metal/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ import {
hasPropertyAccessors
} from 'ember-metal/platform/define_property';
import create from 'ember-metal/platform/create';
import {
filter,
forEach,
indexOf,
map
} from "ember-metal/array";
import Logger from "ember-metal/logger";

import {
Expand Down Expand Up @@ -241,13 +235,6 @@ Ember.platform = {
hasPropertyAccessors: hasPropertyAccessors
};

var EmberArrayPolyfills = Ember.ArrayPolyfills = {};

EmberArrayPolyfills.map = map;
EmberArrayPolyfills.forEach = forEach;
EmberArrayPolyfills.filter = filter;
EmberArrayPolyfills.indexOf = indexOf;

Ember.Error = EmberError;
Ember.guidFor = guidFor;
Ember.META_DESC = META_DESC;
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-metal/lib/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/

import { guidFor } from "ember-metal/utils";
import { indexOf } from "ember-metal/array";
import create from "ember-metal/platform/create";
import { deprecateProperty } from "ember-metal/deprecate_property";

Expand Down Expand Up @@ -150,7 +149,7 @@ OrderedSet.prototype = {

if (presenceSet[guid] === true) {
delete presenceSet[guid];
var index = indexOf.call(list, obj);
var index = list.indexOf(obj);
if (index > -1) {
list.splice(index, 1);
}
Expand Down
14 changes: 4 additions & 10 deletions packages/ember-metal/lib/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

import Ember from "ember-metal/core"; // warn, assert, wrap, et;
import merge from "ember-metal/merge";
import {
indexOf as a_indexOf,
forEach as a_forEach
} from "ember-metal/array";
import o_create from "ember-metal/platform/create";
import { get } from "ember-metal/property_get";
import { set, trySet } from "ember-metal/property_set";
Expand Down Expand Up @@ -266,11 +262,11 @@ function addNormalizedProperty(base, key, value, meta, descs, values, concats, m
descs[key] = value;
values[key] = undefined;
} else {
if ((concats && a_indexOf.call(concats, key) >= 0) ||
if ((concats && concats.indexOf(key) >= 0) ||
key === 'concatenatedProperties' ||
key === 'mergedProperties') {
value = applyConcatenatedProperties(base, key, value, values);
} else if ((mergings && a_indexOf.call(mergings, key) >= 0)) {
} else if ((mergings && mergings.indexOf(key) >= 0)) {
value = applyMergedProperties(base, key, value, values);
} else if (isMethod(value)) {
value = giveMethodSuper(base, key, value, values, descs);
Expand Down Expand Up @@ -313,7 +309,7 @@ function mergeMixins(mixins, m, descs, values, base, keys) {
if (props.hasOwnProperty('toString')) { base.toString = props.toString; }
} else if (currentMixin.mixins) {
mergeMixins(currentMixin.mixins, m, descs, values, base, keys);
if (currentMixin._without) { a_forEach.call(currentMixin._without, removeKeys); }
if (currentMixin._without) { currentMixin._without.forEach(removeKeys); }
}
}
}
Expand Down Expand Up @@ -698,9 +694,7 @@ function _keys(ret, mixin, seen) {
if (props.hasOwnProperty(key)) { ret[key] = true; }
}
} else if (mixin.mixins) {
a_forEach.call(mixin.mixins, (x) => {
_keys(ret, x, seen);
});
mixin.mixins.forEach((x) => _keys(ret, x, seen));
}
}

Expand Down
5 changes: 2 additions & 3 deletions packages/ember-metal/lib/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
watch,
unwatch
} from "ember-metal/watching";
import { map } from "ember-metal/array";
import {
listenersFor,
addListener,
Expand Down Expand Up @@ -90,12 +89,12 @@ export function _suspendObserver(obj, path, target, method, callback) {
}

export function _suspendBeforeObservers(obj, paths, target, method, callback) {
var events = map.call(paths, beforeEvent);
var events = paths.map(beforeEvent);
return suspendListeners(obj, events, target, method, callback);
}

export function _suspendObservers(obj, paths, target, method, callback) {
var events = map.call(paths, changeEvent);
var events = paths.map(changeEvent);
return suspendListeners(obj, events, target, method, callback);
}

Expand Down
5 changes: 2 additions & 3 deletions packages/ember-metal/lib/run_loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Ember from 'ember-metal/core';
import {
GUID_KEY
} from 'ember-metal/utils';
import { indexOf } from 'ember-metal/array';
import {
beginPropertyChanges,
endPropertyChanges
Expand Down Expand Up @@ -654,7 +653,7 @@ function checkAutoRun() {
@private
*/
run._addQueue = function(name, after) {
if (indexOf.call(run.queues, name) === -1) {
run.queues.splice(indexOf.call(run.queues, after)+1, 0, name);
if (run.queues.indexOf(name) === -1) {
run.queues.splice(run.queues.indexOf(after)+1, 0, name);
}
};
3 changes: 1 addition & 2 deletions packages/ember-metal/tests/run_loop/add_queue_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import run from 'ember-metal/run_loop';
import { indexOf } from "ember-metal/array";

var originalQueues = run.queues;
var queues;
Expand All @@ -16,7 +15,7 @@ QUnit.module('system/run_loop/add_queue_test', {
QUnit.test('adds a queue after a specified one', function() {
run._addQueue('testeroo', 'blork');

equal(indexOf.call(queues, 'testeroo'), 1, "new queue was added after specified queue");
equal(queues.indexOf('testeroo'), 1, "new queue was added after specified queue");
});

QUnit.test('does not add the queue if it already exists', function() {
Expand Down
Loading

0 comments on commit 62916e8

Please sign in to comment.