diff options
| author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-02-27 07:23:42 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-27 12:23:42 +0000 | 
| commit | e47a0f488f3d9bbcb76ebcf4f5afe203c1ee06c0 (patch) | |
| tree | 35a4a7411dd3154b19316b330c4976f291f021d2 /ext/js/display | |
| parent | e74fadc5a411e907da088729ea13e23e6f5aa58d (diff) | |
Object utilities (#729)
* Create utilities
* Rename old isObject
* Use new isObject
* Remove old function
* Add additional function
* Simplify for now
* Rename function for clarity
* Rename function
* Expand type
* Update eslint
Diffstat (limited to 'ext/js/display')
| -rw-r--r-- | ext/js/display/display-generator.js | 3 | ||||
| -rw-r--r-- | ext/js/display/display-history.js | 9 | 
2 files changed, 6 insertions, 6 deletions
| diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 0b3236e9..0caf4d71 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -17,7 +17,6 @@   */  import {ExtensionError} from '../core/extension-error.js'; -import {isObject} from '../core/utilities.js';  import {getDisambiguations, getGroupedPronunciations, getTermFrequency, groupKanjiFrequencies, groupTermFrequencies, groupTermTags, isNonNounVerbOrAdjective} from '../dictionary/dictionary-data-util.js';  import {HtmlTemplateCollection} from '../dom/html-template-collection.js';  import {distributeFurigana, getKanaMorae, getPitchCategory, isCodePointKanji} from '../language/ja/japanese.js'; @@ -257,7 +256,7 @@ export class DisplayGenerator {              if (error instanceof DocumentFragment || error instanceof Node) {                  div.appendChild(error);              } else { -                let message = isObject(error) && typeof error.message === 'string' ? error.message : `${error}`; +                let message = error.message;                  let link = null;                  if (error instanceof ExtensionError && error.data !== null && typeof error.data === 'object') {                      const {referenceUrl} = /** @type {import('core').UnknownObject} */ (error.data); diff --git a/ext/js/display/display-history.js b/ext/js/display/display-history.js index bc4f1539..183368d0 100644 --- a/ext/js/display/display-history.js +++ b/ext/js/display/display-history.js @@ -17,7 +17,8 @@   */  import {EventDispatcher} from '../core/event-dispatcher.js'; -import {generateId, isObject} from '../core/utilities.js'; +import {isObjectNotArray} from '../core/object-utilities.js'; +import {generateId} from '../core/utilities.js';  /**   * @augments EventDispatcher<import('display-history').Events> @@ -38,12 +39,12 @@ export class DisplayHistory extends EventDispatcher {          const historyState = history.state;          const {id, state} = ( -            typeof historyState === 'object' && historyState !== null ? +            isObjectNotArray(historyState) ?              historyState :              {id: null, state: null}          );          /** @type {?import('display-history').EntryState} */ -        const stateObject = typeof state === 'object' || state === null ? state : null; +        const stateObject = isObjectNotArray(state) ? state : null;          /** @type {import('display-history').Entry} */          this._current = this._createHistoryEntry(id, location.href, stateObject, null, null);      } @@ -189,7 +190,7 @@ export class DisplayHistory extends EventDispatcher {      _updateStateFromHistory() {          let state = history.state;          let id = null; -        if (isObject(state)) { +        if (isObjectNotArray(state)) {              id = state.id;              if (typeof id === 'string') {                  const entry = this._historyMap.get(id); |