@takeshape/util
Advanced tools
Comparing version 5.9.1 to 5.25.0
@@ -0,1 +1,2 @@ | ||
export * from './types'; | ||
export * from './mime'; | ||
@@ -5,2 +6,3 @@ export * from './gzip'; | ||
export * from './strings'; | ||
export * from './unix-to-iso'; | ||
export * from './unix-to-iso'; | ||
export * from './arrays'; |
@@ -1,3 +0,5 @@ | ||
import mime from 'mime'; | ||
const compressedMimeTypes = new Set(['application/atom+xml', 'application/javascript', 'application/json', 'application/ld+json', 'application/manifest+json', 'application/rdf+xml', 'application/rss+xml', 'application/schema+json', 'application/vnd.geo+json', 'application/vnd.ms-fontobject', 'application/x-font-ttf', 'application/x-javascript', 'application/x-web-app-manifest+json', 'application/xhtml+xml', 'application/xml', 'font/eot', 'font/otf', 'font/opentype', 'image/bmp', 'image/svg+xml', 'image/vnd.microsoft.icon', 'image/x-icon', 'text/cache-manifest', 'text/css', 'text/html', 'text/javascript', 'text/plain', 'text/vcard', 'text/vnd.rim.location.xloc', 'text/vtt', 'text/x-component', 'text/x-cross-domain-policy', 'text/xml']); | ||
import mime from 'mime-types'; | ||
const compressedMimeTypes = new Set(['application/atom+xml', 'application/javascript', 'application/json', 'application/ld+json', 'application/manifest+json', 'application/rdf+xml', 'application/rss+xml', 'application/schema+json', 'application/vnd.geo+json', 'application/vnd.ms-fontobject', 'application/x-font-ttf', 'application/x-javascript', 'application/x-web-app-manifest+json', 'application/xhtml+xml', 'application/xml', 'font/eot', 'font/otf', 'font/opentype', 'image/bmp', 'image/svg+xml', 'image/vnd.microsoft.icon', 'image/x-icon', 'text/cache-manifest', 'text/css', 'text/html', 'text/javascript', 'text/plain', 'text/vcard', 'text/vnd.rim.location.xloc', 'text/vtt', 'text/x-component', 'text/x-cross-domain-policy', 'text/xml']); // application/octetstream | ||
const DEFAULT_TYPE = mime.lookup('bin'); | ||
/** | ||
@@ -10,4 +12,4 @@ * Gets the content type of the file, based on it's extension. | ||
export function contentType(src) { | ||
let type = mime.lookup(src).replace('-', ''); | ||
const charset = mime.charsets.lookup(type); | ||
let type = (mime.lookup(src) || DEFAULT_TYPE).replace('-', ''); | ||
const charset = mime.charset(type); | ||
@@ -28,3 +30,3 @@ if (charset) { | ||
const mimeType = mime.lookup(src); | ||
return compressedMimeTypes.has(mimeType); | ||
return Boolean(mimeType && compressedMimeTypes.has(mimeType)); | ||
} |
@@ -6,2 +6,5 @@ import upperFirst from 'lodash/upperFirst'; | ||
return upperFirst(camelCase(str)); | ||
} | ||
export function isUuid(str) { | ||
return Boolean(str.match(/\w{8,}(-\w{4,}){3,}-\w{12,}/)); | ||
} |
@@ -0,1 +1,2 @@ | ||
export * from './types'; | ||
export * from './mime'; | ||
@@ -6,1 +7,2 @@ export * from './gzip'; | ||
export * from './unix-to-iso'; | ||
export * from './arrays'; |
@@ -7,2 +7,14 @@ "use strict"; | ||
var _types = require("./types"); | ||
Object.keys(_types).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _types[key]; | ||
} | ||
}); | ||
}); | ||
var _mime = require("./mime"); | ||
@@ -66,2 +78,14 @@ | ||
}); | ||
}); | ||
var _arrays = require("./arrays"); | ||
Object.keys(_arrays).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _arrays[key]; | ||
} | ||
}); | ||
}); |
@@ -9,7 +9,9 @@ "use strict"; | ||
var _mime = _interopRequireDefault(require("mime")); | ||
var _mimeTypes = _interopRequireDefault(require("mime-types")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const compressedMimeTypes = new Set(['application/atom+xml', 'application/javascript', 'application/json', 'application/ld+json', 'application/manifest+json', 'application/rdf+xml', 'application/rss+xml', 'application/schema+json', 'application/vnd.geo+json', 'application/vnd.ms-fontobject', 'application/x-font-ttf', 'application/x-javascript', 'application/x-web-app-manifest+json', 'application/xhtml+xml', 'application/xml', 'font/eot', 'font/otf', 'font/opentype', 'image/bmp', 'image/svg+xml', 'image/vnd.microsoft.icon', 'image/x-icon', 'text/cache-manifest', 'text/css', 'text/html', 'text/javascript', 'text/plain', 'text/vcard', 'text/vnd.rim.location.xloc', 'text/vtt', 'text/x-component', 'text/x-cross-domain-policy', 'text/xml']); | ||
const compressedMimeTypes = new Set(['application/atom+xml', 'application/javascript', 'application/json', 'application/ld+json', 'application/manifest+json', 'application/rdf+xml', 'application/rss+xml', 'application/schema+json', 'application/vnd.geo+json', 'application/vnd.ms-fontobject', 'application/x-font-ttf', 'application/x-javascript', 'application/x-web-app-manifest+json', 'application/xhtml+xml', 'application/xml', 'font/eot', 'font/otf', 'font/opentype', 'image/bmp', 'image/svg+xml', 'image/vnd.microsoft.icon', 'image/x-icon', 'text/cache-manifest', 'text/css', 'text/html', 'text/javascript', 'text/plain', 'text/vcard', 'text/vnd.rim.location.xloc', 'text/vtt', 'text/x-component', 'text/x-cross-domain-policy', 'text/xml']); // application/octetstream | ||
const DEFAULT_TYPE = _mimeTypes.default.lookup('bin'); | ||
/** | ||
@@ -21,6 +23,7 @@ * Gets the content type of the file, based on it's extension. | ||
function contentType(src) { | ||
let type = _mime.default.lookup(src).replace('-', ''); | ||
let type = (_mimeTypes.default.lookup(src) || DEFAULT_TYPE).replace('-', ''); | ||
const charset = _mime.default.charsets.lookup(type); | ||
const charset = _mimeTypes.default.charset(type); | ||
@@ -41,5 +44,5 @@ if (charset) { | ||
function shouldCompress(src) { | ||
const mimeType = _mime.default.lookup(src); | ||
const mimeType = _mimeTypes.default.lookup(src); | ||
return compressedMimeTypes.has(mimeType); | ||
return Boolean(mimeType && compressedMimeTypes.has(mimeType)); | ||
} |
export declare const camelCase: (str: string | string[]) => string; | ||
export declare function upperCamel(str: string | string[]): string; | ||
export declare function isUuid(str: string): boolean; |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.upperCamel = upperCamel; | ||
exports.isUuid = isUuid; | ||
exports.camelCase = void 0; | ||
@@ -21,2 +22,6 @@ | ||
return (0, _upperFirst.default)(camelCase(str)); | ||
} | ||
function isUuid(str) { | ||
return Boolean(str.match(/\w{8,}(-\w{4,}){3,}-\w{12,}/)); | ||
} |
{ | ||
"name": "@takeshape/util", | ||
"version": "5.9.1", | ||
"version": "5.25.0", | ||
"homepage": "https://www.takeshape.io", | ||
@@ -65,3 +65,3 @@ "repository": { | ||
"lodash": "^4.17.15", | ||
"mime": "^1.3.4", | ||
"mime-types": "^2.1.27", | ||
"pify": "^5.0.0" | ||
@@ -71,5 +71,5 @@ }, | ||
"@types/lodash": "^4.14.157", | ||
"@types/mime": "1.3.1", | ||
"@types/mime-types": "^2.1.0", | ||
"@types/pify": "^3.0.2" | ||
} | ||
} |
@@ -5,2 +5,3 @@ # Util | ||
A grab-bag of general purpose utility functions. The home for functions that need to be shared but small enough to not warrant their own package | ||
A grab-bag of general purpose utility functions. The home for functions that need to be shared but small enough to not | ||
warrant their own package |
12262
26
257
7
+ Addedmime-types@^2.1.27
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
- Removedmime@^1.3.4
- Removedmime@1.6.0(transitive)