@fxjs/orm-core
Advanced tools
Comparing version 0.1.0 to 0.2.0
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.takeAwayResult = exports.catchBlocking = void 0; | ||
function catchBlocking(executor, args, opts) { | ||
let error, result; | ||
const { thisArg = null } = opts || {}; | ||
try { | ||
result = executor.apply(thisArg, args); | ||
} | ||
catch (ex) { | ||
error = ex; | ||
} | ||
return { error, result }; | ||
} | ||
exports.catchBlocking = catchBlocking; | ||
function takeAwayResult(input, opts) { | ||
const { use_tick = false, callback = null, } = opts || {}; | ||
const isFunc = typeof callback === 'function'; | ||
const { no_throw = isFunc } = opts || {}; | ||
if (!no_throw && input.error) | ||
throw input.error; | ||
if (isFunc) | ||
if (use_tick) | ||
process.nextTick(() => { | ||
callback(input.error, input.result); | ||
}); | ||
else | ||
callback(input.error, input.result); | ||
} | ||
exports.takeAwayResult = takeAwayResult; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.takeAwayResult = exports.catchBlocking = void 0; | ||
exports.Utils = require("./utils"); | ||
var error_1 = require("./error"); | ||
Object.defineProperty(exports, "catchBlocking", { enumerable: true, get: function () { return error_1.catchBlocking; } }); | ||
Object.defineProperty(exports, "takeAwayResult", { enumerable: true, get: function () { return error_1.takeAwayResult; } }); |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.throwErrOrCallabckErrResult = exports.exposeErrAndResultFromSyncMethod = void 0; | ||
function exposeErrAndResultFromSyncMethod(exec, args, opts) { | ||
let error, result; | ||
const { thisArg = null } = opts || {}; | ||
try { | ||
result = exec.apply(thisArg, args); | ||
} | ||
catch (ex) { | ||
error = ex; | ||
} | ||
return { error, result }; | ||
} | ||
exports.exposeErrAndResultFromSyncMethod = exposeErrAndResultFromSyncMethod; | ||
function throwErrOrCallabckErrResult(input, opts) { | ||
const { use_tick = false, callback = null, } = opts || {}; | ||
const { no_throw = false } = opts || {}; | ||
if (!no_throw && input.error) | ||
throw input.error; | ||
if (typeof callback === 'function') | ||
if (use_tick) | ||
process.nextTick(() => { | ||
callback(input.error, input.result); | ||
}); | ||
else | ||
callback(input.error, input.result); | ||
} | ||
exports.throwErrOrCallabckErrResult = throwErrOrCallabckErrResult; | ||
var error_1 = require("./error"); | ||
Object.defineProperty(exports, "exposeErrAndResultFromSyncMethod", { enumerable: true, get: function () { return error_1.catchBlocking; } }); | ||
Object.defineProperty(exports, "throwErrOrCallabckErrResult", { enumerable: true, get: function () { return error_1.takeAwayResult; } }); |
{ | ||
"name": "@fxjs/orm-core", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "", | ||
@@ -21,3 +21,3 @@ "main": "lib", | ||
"devDependencies": { | ||
"@fibjs/types": "^0.31.0", | ||
"@fibjs/types": "^0.34.1", | ||
"fib-pool": "^1.6.0", | ||
@@ -34,12 +34,3 @@ "fib-typify": "^0.8.3" | ||
}, | ||
"ci": { | ||
"type": "travis, appveyor", | ||
"version": [ | ||
"0.28.0", | ||
"0.29.0", | ||
"0.30.0", | ||
"0.31.0" | ||
] | ||
}, | ||
"gitHead": "1c80cd6d5609c80e4ec66f17f56adf27acc4cc60" | ||
"gitHead": "2f11deea2592a9a9919dfdde51ec2b3586fc93f5" | ||
} |
@@ -7,1 +7,11 @@ export declare namespace FxOrmCoreError { | ||
} | ||
import type { FxOrmCoreCallbackNS } from "./callback"; | ||
import type { FxOrmCoreSyncNS } from "./sync"; | ||
export declare function catchBlocking<T = any>(executor: Function, args?: any[], opts?: { | ||
thisArg?: any; | ||
}): FxOrmCoreSyncNS.ExposedResult<T>; | ||
export declare function takeAwayResult<RESULT_T = any>(input: FxOrmCoreSyncNS.ExposedResult<RESULT_T>, opts?: { | ||
callback?: FxOrmCoreCallbackNS.ExecutionCallback<any, RESULT_T>; | ||
use_tick?: boolean; | ||
no_throw?: boolean; | ||
}): void; |
@@ -5,1 +5,3 @@ export import Utils = require('./utils'); | ||
export type { FxOrmCoreError } from './error'; | ||
export type { FxOrmDialect } from './dialect'; | ||
export { catchBlocking, takeAwayResult, } from './error'; |
@@ -1,10 +0,1 @@ | ||
import type { FxOrmCoreCallbackNS } from "./callback"; | ||
import type { FxOrmCoreSyncNS } from "./sync"; | ||
export declare function exposeErrAndResultFromSyncMethod<T = any>(exec: Function, args?: any[], opts?: { | ||
thisArg?: any; | ||
}): FxOrmCoreSyncNS.ExposedResult<T>; | ||
export declare function throwErrOrCallabckErrResult<RESULT_T = any>(input: FxOrmCoreSyncNS.ExposedResult<RESULT_T>, opts?: { | ||
no_throw?: boolean; | ||
callback?: FxOrmCoreCallbackNS.ExecutionCallback<any, RESULT_T>; | ||
use_tick?: boolean; | ||
}): void; | ||
export { catchBlocking as exposeErrAndResultFromSyncMethod, takeAwayResult as throwErrOrCallabckErrResult } from "./error"; |
10189
15
166