Skip to content

Commit 43cb95d

Browse files
committed
feature(package) load.js v3.0.2
1 parent 4a25d03 commit 43cb95d

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

client/_set-emmet.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ module.exports = function() {
2323

2424
exec.if(this._Emmet, () => {
2525
this.setOption('enableEmmet', true);
26-
}, (callback) => {
26+
}, async (callback) => {
2727
const url = _PREFIX + join([
2828
dirVendor + 'emmet.js',
2929
dir + 'ext-emmet.js',
3030
]);
3131

32-
load.js(url, () => {
33-
this._Emmet = ace.require('ace/ext/emmet');
34-
this._Emmet.setCore(window.emmet);
35-
36-
callback();
37-
});
32+
await load.js(url);
33+
34+
this._Emmet = ace.require('ace/ext/emmet');
35+
this._Emmet.setCore(window.emmet);
36+
37+
callback();
3838
});
3939
};
4040

client/edward.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ const smalltalk = require('smalltalk');
1515
const {promisify} = require('es6-promisify');
1616
const jssha = require('jssha');
1717
const restafary = require('restafary/client');
18+
const tryToCatch = require('try-to-catch');
1819

1920
window.load = window.load || load;
2021
window.exec = window.exec || exec;
2122

22-
const loadJSON = promisify(load.json);
23-
2423
const Story = require('./story');
2524
const _clipboard = require('./_clipboard');
2625
const _setEmmet = require('./_set-emmet');
@@ -121,7 +120,7 @@ Edward.prototype._init = function(fn) {
121120
callback();
122121
});
123122
},
124-
() => {
123+
async () => {
125124
this._Emitter = Emitify();
126125
this._Ace = ace.edit(this._Element);
127126
this._Modelist = ace.require('ace/ext/modelist');
@@ -135,23 +134,24 @@ Edward.prototype._init = function(fn) {
135134
this._addCommands();
136135
this._Ace.$blockScrolling = Infinity;
137136

138-
load.json(this._PREFIX + '/edit.json', (error, config) => {
139-
const {
140-
options = {},
141-
} = config;
142-
const preventOverwrite = () => {
143-
for (const name of Object.keys(this._Config.options)) {
144-
options[name] = this._Config.options[name];
145-
}
146-
};
147-
148-
fn();
149-
preventOverwrite();
150-
151-
this._Config = config;
152-
153-
edward.setOptions(options);
154-
});
137+
const config = await load.json(this._PREFIX + '/edit.json');
138+
139+
const {
140+
options = {},
141+
} = config;
142+
143+
const preventOverwrite = () => {
144+
for (const name of Object.keys(this._Config.options)) {
145+
options[name] = this._Config.options[name];
146+
}
147+
};
148+
149+
fn();
150+
preventOverwrite();
151+
152+
this._Config = config;
153+
154+
edward.setOptions(options);
155155
},
156156
]);
157157
};
@@ -461,7 +461,7 @@ Edward.prototype._loadOptions = async function() {
461461
if (this._Options)
462462
return this._Options;
463463

464-
const data = await loadJSON(url);
464+
const data = await load.json(url);
465465

466466
this._Options = data;
467467

@@ -495,14 +495,14 @@ Edward.prototype._diff = function(newValue) {
495495

496496
Edward.prototype._setEmmet = _setEmmet;
497497

498-
Edward.prototype._addExt = function(name, fn) {
498+
Edward.prototype._addExt = async function (name, fn) {
499499
if (this._Ext)
500500
return add(null, this._Ext);
501501

502-
load.json(this._PREFIX + '/json/ext.json', (error, data) => {
503-
this._Ext = data;
504-
add(error, this._Ext);
505-
});
502+
const [error, data] = await tryToCatch(load.json, this._PREFIX + '/json/ext.json');
503+
this._Ext = data;
504+
505+
add(error, this._Ext);
506506

507507
function add(error, exts) {
508508
if (error)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"eslint-plugin-putout": "^2.0.0",
7575
"execon": "^1.2.9",
7676
"jssha": "^2.3.1",
77-
"load.js": "^2.0.0",
77+
"load.js": "^3.0.2",
7878
"madrun": "^3.0.1",
7979
"nodemon": "^1.11.0",
8080
"once": "^1.4.0",

0 commit comments

Comments
 (0)