Use [].inclues where appropriate

This commit is contained in:
Kevin Sawicki 2016-01-15 09:30:29 -08:00
parent c2d473cf65
commit 2833db78ad
3 changed files with 7 additions and 6 deletions

View file

@ -4,6 +4,7 @@ const binding = process.atomBinding('dialog');
const v8Util = process.atomBinding('v8_util');
var slice = [].slice;
var includes = [].includes;
var indexOf = [].indexOf;
var fileDialogProperties = {
@ -61,7 +62,7 @@ module.exports = {
properties = 0;
for (prop in fileDialogProperties) {
value = fileDialogProperties[prop];
if (indexOf.call(options.properties, prop) >= 0) {
if (includes.call(options.properties, prop)) {
properties |= value;
}
}

View file

@ -2,7 +2,7 @@ const ipcRenderer = require('electron').ipcRenderer;
const nativeImage = require('electron').nativeImage;
var nextId = 0;
var indexOf = [].indexOf;
var includes = [].includes;
var getNextId = function() {
return ++nextId;
@ -18,8 +18,8 @@ exports.getSources = function(options, callback) {
if (!isValid(options)) {
return callback(new Error('Invalid options'));
}
captureWindow = indexOf.call(options.types, 'window') >= 0;
captureScreen = indexOf.call(options.types, 'screen') >= 0;
captureWindow = includes.call(options.types, 'window');
captureScreen = includes.call(options.types, 'screen');
if (options.thumbnailSize == null) {
options.thumbnailSize = {
width: 150,

View file

@ -4,12 +4,12 @@ const v8Util = process.atomBinding('v8_util');
const callbacksRegistry = new CallbacksRegistry;
var indexOf = [].indexOf;
var includes = [].includes;
// Check for circular reference.
var isCircular = function(field, visited) {
if (typeof field === 'object') {
if (indexOf.call(visited, field) >= 0) {
if (includes.call(visited, field)) {
return true;
}
visited.push(field);