Skip to content

Commit 66505db

Browse files
author
Ari
committed
Removed dist
2 parents ca23378 + c016f81 commit 66505db

File tree

5 files changed

+41
-17
lines changed

5 files changed

+41
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ npm-debug.log
88
node_modules
99
.env
1010
public/
11+
dist

dist/lib/String.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(function (global, factory) {
2+
if (typeof define === "function" && define.amd) {
3+
define(['exports'], factory);
4+
} else if (typeof exports !== "undefined") {
5+
factory(exports);
6+
} else {
7+
var mod = {
8+
exports: {}
9+
};
10+
factory(mod.exports);
11+
global.String = mod.exports;
12+
}
13+
})(this, function (exports) {
14+
'use strict';
15+
16+
Object.defineProperty(exports, "__esModule", {
17+
value: true
18+
});
19+
var camelize = exports.camelize = function camelize(str) {
20+
return str.split(' ').map(function (word) {
21+
return word.charAt(0).toUpperCase() + word.slice(1);
22+
}).join('');
23+
};
24+
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"index.d.ts"
1818
],
1919
"types": "index.d.ts",
20+
"sideEffects": false,
2021
"scripts": {
2122
"prepublish": "./scripts/prepublish.sh",
2223
"preversion": ". ./scripts/prepublish.sh",

src/lib/ScriptCache.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const window = require('./windowOrGlobal');
55
export const ScriptCache = (function(global) {
66
global._scriptMap = global._scriptMap || scriptMap;
77
return function ScriptCache(scripts) {
8-
const Cache = {}
8+
const Cache = {};
99

1010
Cache._onLoad = function(key) {
1111
return (cb) => {
@@ -24,14 +24,14 @@ export const ScriptCache = (function(global) {
2424
}
2525

2626
return stored;
27-
});
27+
}).catch(error => cb(error));
2828
} else {
2929
// TODO:
3030
}
3131

3232
return unregister;
3333
}
34-
}
34+
};
3535

3636
Cache._scriptTag = (key, src) => {
3737
if (!scriptMap.has(key)) {
@@ -41,9 +41,7 @@ export const ScriptCache = (function(global) {
4141

4242
let tag = document.createElement('script');
4343
let promise = new Promise((resolve, reject) => {
44-
let resolved = false,
45-
errored = false,
46-
body = document.getElementsByTagName('body')[0];
44+
let body = document.getElementsByTagName('body')[0];
4745

4846
tag.type = 'text/javascript';
4947
tag.async = false; // Load in order
@@ -69,24 +67,24 @@ export const ScriptCache = (function(global) {
6967

7068
cleanup();
7169
}
72-
}
70+
};
7371

7472
const cleanup = () => {
7573
if (global[cbName] && typeof global[cbName] === 'function') {
7674
global[cbName] = null;
7775
delete global[cbName]
7876
}
79-
}
77+
};
8078

8179
tag.onload = handleResult('loaded');
82-
tag.onerror = handleResult('error')
80+
tag.onerror = handleResult('error');
8381
tag.onreadystatechange = () => {
8482
handleResult(tag.readyState)
85-
}
83+
};
8684

8785
// Pick off callback, if there is one
8886
if (src.match(/callback=CALLBACK_NAME/)) {
89-
src = src.replace(/(callback=)[^\&]+/, `$1${cbName}`)
87+
src = src.replace(/(callback=)[^\&]+/, `$1${cbName}`);
9088
cb = window[cbName] = tag.onload;
9189
} else {
9290
tag.addEventListener('load', tag.onload)
@@ -101,13 +99,13 @@ export const ScriptCache = (function(global) {
10199
let initialState = {
102100
loaded: false,
103101
error: false,
104-
promise: promise,
102+
promise,
105103
tag
106-
}
104+
};
107105
scriptMap.set(key, initialState);
108106
}
109-
return scriptMap.get(key);
110-
}
107+
return scriptMap.get(key).tag;
108+
};
111109

112110
// let scriptTags = document.querySelectorAll('script')
113111
//
@@ -132,7 +130,7 @@ export const ScriptCache = (function(global) {
132130
tag: tag,
133131
onLoad: Cache._onLoad(key),
134132
}
135-
})
133+
});
136134

137135
return Cache;
138136
}

src/lib/String.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const camelize = function(str) {
2-
return str.split(' ').map(function(word) {
2+
return str.split('_').map(function(word) {
33
return word.charAt(0).toUpperCase() + word.slice(1);
44
}).join('');
55
}

0 commit comments

Comments
 (0)