Lighten deps

This commit is contained in:
Travis Shivers 2020-07-31 15:45:20 -05:00
parent 8c414596de
commit 06f6191c27
No known key found for this signature in database
GPG Key ID: EE4CC2891B8FCD33
12 changed files with 42 additions and 32 deletions

View File

@ -1,4 +1,5 @@
> 3%
last 1 Chrome versions
last 1 Firefox versions
last 1 Safari versions
last 1 Edge version

12
package-lock.json generated
View File

@ -6299,12 +6299,6 @@
"integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==",
"dev": true
},
"humanize-duration": {
"version": "3.23.1",
"resolved": "https://registry.npmjs.org/humanize-duration/-/humanize-duration-3.23.1.tgz",
"integrity": "sha512-aoOEkomAETmVuQyBx4E7/LfPlC9s8pAA/USl7vFRQpDjepo3aiyvFfOhtXSDqPowdBVPFUZ7onG/KyuolX0qPg==",
"dev": true
},
"iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
@ -7269,12 +7263,6 @@
"integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==",
"dev": true
},
"lodash-es": {
"version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.15.tgz",
"integrity": "sha512-rlrc3yU3+JNOpZ9zj5pQtxnx2THmvRykwL4Xlxoa8I9lHBlVbbyPhgyPMioxVZ4NqyxaVVtaJnzsyOidQIhyyQ==",
"dev": true
},
"lodash.defaultsdeep": {
"version": "4.6.1",
"resolved": "https://registry.npmjs.org/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.1.tgz",

View File

@ -32,10 +32,8 @@
"eslint-plugin-vue": "^6.2.2",
"fast-xml-parser": "^3.17.4",
"fscreen": "^1.0.2",
"humanize-duration": "^3.23.1",
"last-commit-log": "^3.0.4",
"libjass": "^0.11.0",
"lodash-es": "^4.17.15",
"nconf": "^0.10.0",
"sass": "^1.26.10",
"sass-loader": "^8.0.2",

View File

@ -1,5 +1,5 @@
import { detect } from 'detect-browser';
import { intersection } from 'lodash-es';
import { intersection } from '@/utils/lightlodash';
import { makeUrl } from '@/utils/fetchutils';
function capitalizeFirstLetter(string) {

View File

@ -1,4 +1,4 @@
import { sample } from 'lodash-es';
import { sample } from '@/utils/lightlodash';
import { fetchJson } from '@/utils/fetchutils';
import scoreMedia from './mediascoring';

View File

@ -1,4 +1,4 @@
import { difference, intersection } from 'lodash-es';
import { difference, intersection } from '@/utils/lightlodash';
import { makeUrl } from '@/utils/fetchutils';
export default {

View File

@ -0,0 +1,10 @@
import { intervalToDuration, formatDuration } from 'date-fns';
// https://github.com/date-fns/date-fns/issues/229
const customFormatDuration = ({ start, end }) => {
const durations = intervalToDuration({ start, end });
return formatDuration(durations);
};
export default customFormatDuration;

21
src/utils/lightlodash.js Normal file
View File

@ -0,0 +1,21 @@
export const sample = (arr) => {
const len = arr == null ? 0 : arr.length;
return len ? arr[Math.floor(Math.random() * len)] : undefined;
};
export const difference = (arrays) => arrays.reduce((a, b) => a.filter((c) => !b.includes(c)));
export const intersection = (arrays) => arrays.reduce((a, b) => a.filter((c) => b.includes(c)));
export const debounce = (func, wait, immediate) => {
let timeout;
return function debouncedFunc(...args) {
const context = this;
clearTimeout(timeout);
timeout = setTimeout(() => {
timeout = null;
if (!immediate) func.apply(context, ...args);
}, wait);
if (immediate && !timeout) func.apply(context, ...args);
};
};

View File

@ -301,7 +301,7 @@
<script>
import { mapActions, mapGetters, mapMutations } from 'vuex';
import { debounce } from 'lodash-es';
import { debounce } from '@/utils/lightlodash';
export default {
name: 'Plexbrowser',

View File

@ -492,7 +492,7 @@
<script>
import { mapActions, mapGetters, mapMutations } from 'vuex';
import humanizeDuration from 'humanize-duration';
import customFormatDuration from '@/utils/customformatduration';
import sizing from '@/mixins/sizing';
@ -581,11 +581,7 @@ export default {
},
length() {
return humanizeDuration(this.contents.duration, {
delimiter: ' ',
units: ['h', 'm'],
round: true,
});
return this.getDuration(this.contents.duration);
},
title() {
@ -729,12 +725,8 @@ export default {
this.dialog = false;
},
getDuration(dur) {
return humanizeDuration(dur, {
delimiter: ' ',
units: ['h', 'm', 's'],
round: true,
});
getDuration(end) {
return customFormatDuration({ start: 0, end });
},
getStreamCount(streams, type) {

View File

@ -43,7 +43,7 @@
<script>
import { mapActions, mapGetters, mapMutations } from 'vuex';
import { sample } from 'lodash-es';
import { sample } from '@/utils/lightlodash';
import sizing from '@/mixins/sizing';

View File

@ -194,7 +194,7 @@
</template>
<script>
import { sample } from 'lodash-es';
import { sample } from '@/utils/lightlodash';
import { mapActions, mapGetters, mapMutations } from 'vuex';
import sizing from '@/mixins/sizing';