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;