avet-utils
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -17,3 +17,3 @@ function printAndExit(message) { | ||
var property = str.replace(/^@(\w+)\//, function (s, s1) { | ||
return s1 + "_"; | ||
return s1 + '_'; | ||
}).replace(/[_-][a-z]/gi, function (s) { | ||
@@ -28,5 +28,15 @@ return s.substring(1).toUpperCase(); | ||
function isServer() { | ||
return typeof window === 'undefined'; | ||
} | ||
function isBrowser() { | ||
return typeof window !== 'undefined'; | ||
} | ||
module.exports = { | ||
printAndExit: printAndExit, | ||
strUpperCamelize: strUpperCamelize | ||
strUpperCamelize: strUpperCamelize, | ||
isServer: isServer, | ||
isBrowser: isBrowser | ||
}; |
@@ -13,3 +13,3 @@ 'use strict'; | ||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(Component, ctx) { | ||
var props, compName, message; | ||
var getProps, props, compName, message; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
@@ -19,4 +19,6 @@ while (1) { | ||
case 0: | ||
if (Component.getInitialProps) { | ||
_context.next = 2; | ||
getProps = Component.getInitialProps || Component.getProps; | ||
if (getProps) { | ||
_context.next = 3; | ||
break; | ||
@@ -27,11 +29,11 @@ } | ||
case 2: | ||
_context.next = 4; | ||
return Component.getInitialProps(ctx); | ||
case 3: | ||
_context.next = 5; | ||
return getProps(ctx); | ||
case 4: | ||
case 5: | ||
props = _context.sent; | ||
if (!(ctx.res && isResSent(ctx.res))) { | ||
_context.next = 7; | ||
_context.next = 8; | ||
break; | ||
@@ -42,5 +44,5 @@ } | ||
case 7: | ||
case 8: | ||
if (props) { | ||
_context.next = 11; | ||
_context.next = 12; | ||
break; | ||
@@ -50,9 +52,9 @@ } | ||
compName = getDisplayName(Component); | ||
message = '"' + compName + '.getInitialProps()" should resolve to an object. But found "' + props + '" instead.'; | ||
message = '"' + compName + '.getInitialProps() or ' + compName + '.getProps" should resolve to an object. But found "' + props + '" instead.'; | ||
throw new Error(message); | ||
case 11: | ||
case 12: | ||
return _context.abrupt('return', props); | ||
case 12: | ||
case 13: | ||
case 'end': | ||
@@ -70,2 +72,58 @@ return _context.stop(); | ||
var loadGetStore = function () { | ||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(Component, ctx) { | ||
var getStore, store, compName, message; | ||
return _regenerator2.default.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
getStore = Component.getStore; | ||
if (getStore) { | ||
_context2.next = 3; | ||
break; | ||
} | ||
return _context2.abrupt('return', {}); | ||
case 3: | ||
_context2.next = 5; | ||
return getStore(ctx); | ||
case 5: | ||
store = _context2.sent; | ||
if (!(ctx.res && isResSent(ctx.res))) { | ||
_context2.next = 8; | ||
break; | ||
} | ||
return _context2.abrupt('return', store); | ||
case 8: | ||
if (store) { | ||
_context2.next = 12; | ||
break; | ||
} | ||
compName = getDisplayName(Component); | ||
message = '"' + compName + '.getStore()" should resolve to an object. But found "' + store + '" instead.'; | ||
throw new Error(message); | ||
case 12: | ||
return _context2.abrupt('return', store); | ||
case 13: | ||
case 'end': | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, this); | ||
})); | ||
return function loadGetStore(_x3, _x4) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}(); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -84,3 +142,5 @@ | ||
getDisplayName: getDisplayName, | ||
loadGetStore: loadGetStore, | ||
loadGetProps: loadGetInitialProps, | ||
loadGetInitialProps: loadGetInitialProps | ||
}; |
{ | ||
"name": "avet-utils", | ||
"description": "Avet utils for all avet projects", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"scripts": { | ||
@@ -6,0 +6,0 @@ "dev": "taskr dev", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19775
531