From 9f971b85fbc84ebd031b3cca82441eaf87bb9666 Mon Sep 17 00:00:00 2001 From: Suren Atoyan Date: Thu, 7 Jan 2021 18:32:41 +0400 Subject: [PATCH] collect remaining utilities all in the entry file / add some new ones for the next version --- src/utils/index.js | 27 +++++++++++++++++++++------ src/utils/noop.js | 3 --- 2 files changed, 21 insertions(+), 9 deletions(-) delete mode 100644 src/utils/noop.js diff --git a/src/utils/index.js b/src/utils/index.js index 5846078..df9f92a 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,8 +1,23 @@ -import noop from './noop'; -import compose from './compose'; -import deepMerge from './deepMerge'; -import makeCancelable from './makeCancelable'; +function noop() {} -import monaco from './monaco'; +function getOrCreateModel(monaco, value, language, path) { + return getModel(monaco, path) || createModel(monaco, value, language, path); +} -export { noop, compose, deepMerge, makeCancelable, monaco }; +function getModel(monaco, path) { + return monaco + .editor + .getModel(crateModelUri(monaco, path)); +} + +function createModel(monaco, value, language, path) { + return monaco + .editor + .createModel(value, language, crateModelUri(monaco, path)); +} + +function crateModelUri(monaco, path) { + return monaco.Uri.parse(path); +} + +export { noop, getOrCreateModel }; diff --git a/src/utils/noop.js b/src/utils/noop.js deleted file mode 100644 index 77787df..0000000 --- a/src/utils/noop.js +++ /dev/null @@ -1,3 +0,0 @@ -const noop = () => {}; - -export default noop;