mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Remove unused BreakString class (#8942)
This commit is contained in:
@@ -1,54 +1,3 @@
|
||||
/* global BreakString:true */
|
||||
|
||||
/*
|
||||
* memoize.js
|
||||
* by @philogb and @addyosmani
|
||||
* with further optimizations by @mathias
|
||||
* and @DmitryBaranovsk
|
||||
* perf tests: http://bit.ly/q3zpG3
|
||||
* Released under an MIT license.
|
||||
*
|
||||
* modified with cap by Sam
|
||||
*/
|
||||
function cappedMemoize(fn, max) {
|
||||
fn.maxMemoize = max;
|
||||
fn.memoizeLength = 0;
|
||||
|
||||
return function() {
|
||||
const args = Array.prototype.slice.call(arguments);
|
||||
let hash = "";
|
||||
let i = args.length;
|
||||
let currentArg = null;
|
||||
while (i--) {
|
||||
currentArg = args[i];
|
||||
hash +=
|
||||
currentArg === new Object(currentArg)
|
||||
? JSON.stringify(currentArg)
|
||||
: currentArg;
|
||||
if (!fn.memoize) {
|
||||
fn.memoize = {};
|
||||
}
|
||||
}
|
||||
if (hash in fn.memoize) {
|
||||
return fn.memoize[hash];
|
||||
} else {
|
||||
fn.memoizeLength++;
|
||||
if (fn.memoizeLength > max) {
|
||||
fn.memoizeLength = 0;
|
||||
fn.memoize = {};
|
||||
}
|
||||
const result = fn.apply(this, args);
|
||||
fn.memoize[hash] = result;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const breakUp = cappedMemoize(function(str, hint) {
|
||||
return new BreakString(str).break(hint);
|
||||
}, 100);
|
||||
export { breakUp };
|
||||
|
||||
export function shortDate(date) {
|
||||
return moment(date).format(I18n.t("dates.medium.date_year"));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
//= require mousetrap-global-bind.js
|
||||
//= require rsvp.js
|
||||
//= require show-html.js
|
||||
//= require break_string
|
||||
//= require buffered-proxy
|
||||
//= require jquery.autoellipsis-1.0.10
|
||||
//= require virtual-dom
|
||||
|
||||
Reference in New Issue
Block a user