Skip to content

Commit 65f9b9f

Browse files
committed
remove underscore
1 parent 03e693f commit 65f9b9f

File tree

11 files changed

+48
-32
lines changed

11 files changed

+48
-32
lines changed

lib/core.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
import * as _ from 'underscore';
32
import * as urlLib from 'url';
43
import * as pluginUtils from './loader/utils.js';
54
import * as utils from './utils.js';
@@ -12,6 +11,7 @@
1211
import * as htmlUtils from './html-utils.js';
1312
import * as metaUtils from './plugins/system/meta/utils.js';
1413
import mediaPlugin from './plugins/validators/media.js';
14+
import { difference, intersection } from '../utils.js';
1515

1616
const plugins = pluginLoader._plugins,
1717
pluginsModules = pluginLoader._pluginsModules,
@@ -92,7 +92,7 @@
9292
* mandatoryParams - list of new params not used by plugins. Core will find what can use them.
9393
* 'mandatoryParams' enables mandatory mode: function will use _only_ methods which has this input 'mandatoryParams'.
9494
* This is used for "go down by tree" algorithm.
95-
* var mandatoryParams = _.difference(loadedParams, Object.keys(usedParams));
95+
* var mandatoryParams = difference(loadedParams, Object.keys(usedParams));
9696
* mandatoryParams = [
9797
* paramName
9898
* ]
@@ -140,13 +140,13 @@
140140

141141
// If mandatory params mode.
142142
if (mandatoryParams && mandatoryParams.length > 0) {
143-
if (_.intersection(params, mandatoryParams).length === 0) {
143+
if (intersection(params, mandatoryParams).length === 0) {
144144
// Skip method if its not using mandatory params.
145145
continue;
146146
}
147147
}
148148

149-
var absentParams = _.difference(params, loadedParams);
149+
var absentParams = difference(params, loadedParams);
150150

151151
// If "__" (as in "__statusCode") or "...Error" (as in "oembedError")
152152
// super mandatory params are absent - skip the plugin.
@@ -362,7 +362,7 @@
362362

363363
var loadedParams = Object.keys(context);
364364

365-
// var mandatoryParams = _.difference(loadedParams, Object.keys(usedParams));
365+
// var mandatoryParams = difference(loadedParams, Object.keys(usedParams));
366366

367367
// Reset scanned plugins for each iteration.
368368
var scannedPluginsIds = {};
@@ -1296,7 +1296,7 @@
12961296

12971297
// Sort links in order of REL according to CONFIG.REL_GROUPS.
12981298
function getRelIndex(rel) {
1299-
var rels = _.intersection(rel, CONFIG.REL_GROUPS);
1299+
var rels = intersection(rel, CONFIG.REL_GROUPS);
13001300
var gr = CONFIG.REL_GROUPS.length + 1;
13011301
if (rels.length > 0) {
13021302
for(var i = 0; i < rels.length; i++) {

lib/html-utils.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import * as cheerio from 'cheerio';
2-
3-
import * as _ from 'underscore';
42
import CONFIG from '../config.loader.js';
53

64
var defaultPaddingBottom = 100 / CONFIG.DEFAULT_ASPECT_RATIO;

lib/oembed.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as _ from 'underscore';
21
import * as htmlUtils from './html-utils.js';
2+
import { intersection } from '../utils.js';
33

44
export function getOembed(uri, data, options) {
55

@@ -80,7 +80,7 @@ export function getOembed(uri, data, options) {
8080
}
8181
}
8282

83-
var inlineReader = link && _.intersection(link.rel, [CONFIG.R.inline, CONFIG.R.reader]).length == 2;
83+
var inlineReader = link && intersection(link.rel, [CONFIG.R.inline, CONFIG.R.reader]).length == 2;
8484

8585
var m = link && link.media;
8686
if (m) {

lib/whitelist.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import * as fs from 'fs';
33
import * as path from 'path';
44
import * as crypto from 'crypto';
5-
import * as _ from 'underscore';
65
import * as utils from './utils.js';
76
import log from '../logging.js';
87
import got from 'got';
@@ -11,6 +10,7 @@
1110
import { dirname } from 'path';
1211

1312
import CONFIG from '../config.loader.js';
13+
import { intersection, unique } from '../utils.js';
1414

1515
const __filename = fileURLToPath(import.meta.url);
1616
const __dirname = dirname(__filename);
@@ -57,7 +57,7 @@
5757

5858
var result = [];
5959

60-
var sources = _.intersection(rels, CONFIG.KNOWN_SOURCES);
60+
var sources = intersection(rels, CONFIG.KNOWN_SOURCES);
6161

6262
if (sources.length == 0 && rels.indexOf("player") > -1) {
6363

@@ -156,7 +156,7 @@
156156
var tags = links.map(function(link) {
157157
return getTags.apply(that, [link.source, link.type]);
158158
});
159-
tags = _.unique(tags.flat());
159+
tags = unique(tags.flat());
160160
// Remove allow if denied.
161161
var allowIdx = tags.indexOf("allow");
162162
var denyIdx = tags.indexOf("deny");

modules/api/views.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as iframelyCore from '../../lib/core.js';
22
import * as utils from '../../utils.js';
3-
import * as _ from 'underscore';
43
import * as async from 'async';
54
import { cache } from '../../lib/cache.js';
65
import * as iframelyUtils from '../../lib/utils.js';
@@ -231,7 +230,7 @@ export default function(app) {
231230
});
232231

233232
var other = links.filter(function(link) {
234-
return _.intersection(link.rel, CONFIG.REL_GROUPS).length == 0
233+
return utils.intersection(link.rel, CONFIG.REL_GROUPS).length == 0
235234
});
236235
if (other.length) {
237236
groups.other = other;

modules/tests-ui/tester.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ if (!CONFIG.tests) {
1010
process.title = "iframely-tests";
1111

1212
import * as async from 'async';
13-
import * as _ from 'underscore';
1413
import * as models from './models.js';
1514
import * as utils from './utils.js';
1615
import { run as iframely } from '../../lib/core.js';
1716
import * as whitelist from '../../lib/whitelist.js';
1817
import * as pluginLoader from '../../lib/loader/pluginLoader.js';
18+
import { difference } from '../../utils.js';
1919
var plugins = pluginLoader._plugins;
2020

2121
var testOnePlugin = false;
@@ -106,7 +106,7 @@ function createNewPluginTests(providersIds, cb) {
106106

107107
function(ids, cb) {
108108

109-
var newIds = _.difference(providersIds, ids);
109+
var newIds = difference(providersIds, ids);
110110

111111
async.eachSeries(newIds, function(id, cb) {
112112

modules/tests-ui/utils.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as _ from 'underscore';
21
import FeedParser from 'feedparser';
32
import got from 'got';
43
import * as async from 'async';
@@ -8,6 +7,7 @@ import { findWhitelistRecordFor } from '../../lib/whitelist.js';
87
import { getPluginData as iframelyGetPluginData } from '../../lib/core.js';
98
import * as pluginLoader from '../../lib/loader/pluginLoader.js';
109
import * as pluginUtils from '../../lib/loader/utils.js';
10+
import { difference, intersection, union } from '../../utils.js';
1111

1212
var plugins = pluginLoader._plugins,
1313
pluginsList = pluginLoader._pluginsList,
@@ -226,8 +226,8 @@ export function getPluginUnusedMethods(pluginId, debugData) {
226226

227227
return {
228228
allMandatoryMethods: pluginMethods.mandatory,
229-
mandatory: _.difference(pluginMethods.mandatory, usedMethods),
230-
skipped: _.difference(pluginMethods.skipped, usedMethods)
229+
mandatory: difference(pluginMethods.mandatory, usedMethods),
230+
skipped: difference(pluginMethods.skipped, usedMethods)
231231
};
232232
};
233233

@@ -435,9 +435,9 @@ function findAllPluginMethods(pluginId, plugins, result, skipped) {
435435
var skipMethods = [];
436436
var tests = plugin.module.tests;
437437
tests && tests.forEach && tests.forEach(function(test) {
438-
skipMixins = _.union(skipMixins, test.skipMixins, globalSkipMixins);
438+
skipMixins = union(skipMixins, test.skipMixins, globalSkipMixins);
439439
if (test.skipMethods) {
440-
skipMethods = _.union(skipMethods, test.skipMethods);
440+
skipMethods = union(skipMethods, test.skipMethods);
441441
}
442442
});
443443

@@ -500,7 +500,7 @@ function findUsedMethods(options, debugData, result) {
500500

501501
if (options.findByData) {
502502
try {
503-
good = _.intersection(Object.keys(l), options.findByData).length > 0;
503+
good = intersection(Object.keys(l), options.findByData).length > 0;
504504
} catch(ex) {
505505
good = false;
506506
}
@@ -525,7 +525,7 @@ function findUsedMethods(options, debugData, result) {
525525

526526
// Find parent data source.
527527

528-
var findSourceForRequirements = _.difference(params, DEFAULT_PARAMS);
528+
var findSourceForRequirements = difference(params, DEFAULT_PARAMS);
529529

530530
if (findSourceForRequirements.length > 0) {
531531
findUsedMethods({

modules/tests-ui/views.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as async from 'async';
22
import moment from 'moment';
3-
import * as _ from 'underscore';
43
import { exec as exec } from 'child_process';
54
import * as models from './models.js';
65
import * as utils from './utils.js';
6+
import { difference } from '../../utils.js';
77

88
var PluginTest = models.PluginTest;
99
var TestingProgress = models.TestingProgress;
@@ -113,7 +113,7 @@
113113
}
114114

115115
pluginTest.failedUrls = logs.length - pluginTest.passedUrls;
116-
pluginTest.pendingUrls = _.difference(pluginTest.last_urls_set.urls, testedUrls).length;
116+
pluginTest.pendingUrls = difference(pluginTest.last_urls_set.urls, testedUrls).length;
117117
pluginTest.hasError = pluginTest.failedUrls > 0;
118118
// TODO: do something with this?
119119
pluginTest.hasGeneralError = pluginTest.error || pluginTest.last_urls_set.hasError();

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@
4747
"redis": "^4.6.14",
4848
"redis-clustr": "1.7.0",
4949
"sax": "^1.2.4",
50-
"send": "^1.2.0",
51-
"underscore": "^1.13.6"
50+
"send": "^1.2.0"
5251
},
5352
"devDependencies": {
5453
"chai": "^6.2.0",

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)