@boost/common
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -0,1 +1,10 @@ | ||
## 1.1.0 - 2019-06-21 | ||
#### 🚀 Updates | ||
- Added `formatMs`, `instanceOf`, `isEmpty`, `isObject`, `parseFile`, `requireModule`, and `toArray` | ||
helper functions. | ||
- Added `Contract#configure` as a means to update the options object after instantiation. | ||
- Updated the `Contract` options object to be frozen after each configure. | ||
### 1.0.1 - 2019-05-09 | ||
@@ -2,0 +11,0 @@ |
@@ -6,3 +6,14 @@ import { Blueprint, Predicates } from 'optimal'; | ||
constructor(options?: T); | ||
/** | ||
* Set an options object by merging the new partial and existing options | ||
* with the defined blueprint, while running all validation checks. | ||
* Freeze and return the options object. | ||
*/ | ||
configure(options?: Partial<T>): Required<T>; | ||
/** | ||
* Define an optimal blueprint in which to validate and build the | ||
* options object passed to the constructor, or when manual setting. | ||
*/ | ||
abstract blueprint(predicates: Predicates): Blueprint<T>; | ||
} | ||
//# sourceMappingURL=Contract.d.ts.map |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
@@ -21,11 +10,21 @@ if (mod && mod.__esModule) return mod; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var optimal_1 = __importStar(require("optimal")); | ||
var Contract = (function () { | ||
function Contract(options) { | ||
this.options = optimal_1.default(__assign({}, options), this.blueprint(optimal_1.predicates), { | ||
const optimal_1 = __importStar(require("optimal")); | ||
class Contract { | ||
constructor(options) { | ||
this.options = this.configure(options); | ||
} | ||
/** | ||
* Set an options object by merging the new partial and existing options | ||
* with the defined blueprint, while running all validation checks. | ||
* Freeze and return the options object. | ||
*/ | ||
configure(options) { | ||
// We don't want the options property to be modified directly, | ||
// so it's read only, but we still want to modify it with this function. | ||
this.options = Object.freeze(optimal_1.default(Object.assign({}, this.options, options), this.blueprint(optimal_1.predicates), { | ||
name: this.constructor.name, | ||
}); | ||
})); | ||
return this.options; | ||
} | ||
return Contract; | ||
}()); | ||
} | ||
exports.default = Contract; |
@@ -0,4 +1,16 @@ | ||
/** | ||
* @copyright 2017-2019, Miles Johnson | ||
* @license https://opensource.org/licenses/MIT | ||
*/ | ||
import { Blueprint, Predicates } from 'optimal'; | ||
import Contract from './Contract'; | ||
import formatMs from './helpers/formatMs'; | ||
import instanceOf from './helpers/instanceOf'; | ||
import isEmpty from './helpers/isEmpty'; | ||
import isObject from './helpers/isObject'; | ||
import parseFile from './helpers/parseFile'; | ||
import requireModule from './helpers/requireModule'; | ||
import toArray from './helpers/toArray'; | ||
export * from './types'; | ||
export { Contract, Blueprint, Predicates }; | ||
export { Contract, Blueprint, Predicates, formatMs, instanceOf, isEmpty, isObject, parseFile, requireModule, toArray, }; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
/** | ||
* @copyright 2017-2019, Miles Johnson | ||
* @license https://opensource.org/licenses/MIT | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -6,3 +10,17 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Contract_1 = __importDefault(require("./Contract")); | ||
const Contract_1 = __importDefault(require("./Contract")); | ||
exports.Contract = Contract_1.default; | ||
const formatMs_1 = __importDefault(require("./helpers/formatMs")); | ||
exports.formatMs = formatMs_1.default; | ||
const instanceOf_1 = __importDefault(require("./helpers/instanceOf")); | ||
exports.instanceOf = instanceOf_1.default; | ||
const isEmpty_1 = __importDefault(require("./helpers/isEmpty")); | ||
exports.isEmpty = isEmpty_1.default; | ||
const isObject_1 = __importDefault(require("./helpers/isObject")); | ||
exports.isObject = isObject_1.default; | ||
const parseFile_1 = __importDefault(require("./helpers/parseFile")); | ||
exports.parseFile = parseFile_1.default; | ||
const requireModule_1 = __importDefault(require("./helpers/requireModule")); | ||
exports.requireModule = requireModule_1.default; | ||
const toArray_1 = __importDefault(require("./helpers/toArray")); | ||
exports.toArray = toArray_1.default; |
import { Blueprint, Predicates } from 'optimal'; | ||
export declare type Path = string; | ||
export declare type AbstractConstructor<T> = Function & { | ||
prototype: T; | ||
}; | ||
export declare type ConcreteConstructor<T> = new (...args: any[]) => T; | ||
export declare type Constructor<T> = AbstractConstructor<T> | ConcreteConstructor<T>; | ||
export interface Optionable<T extends object = {}> { | ||
@@ -6,1 +12,2 @@ readonly options: Required<T>; | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@boost/common", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Common utilities for Boost applications.", | ||
@@ -21,2 +21,7 @@ "keywords": [ | ||
}, | ||
"dependencies": { | ||
"js-yaml": "^3.13.1", | ||
"json5": "^2.1.0", | ||
"pretty-ms": "^5.0.0" | ||
}, | ||
"peerDependencies": { | ||
@@ -26,5 +31,8 @@ "optimal": "^3.0.0" | ||
"devDependencies": { | ||
"@boost/test-utils": "^1.2.2", | ||
"@types/js-yaml": "^3.12.1", | ||
"@types/json5": "^0.0.30", | ||
"optimal": "^3.2.1" | ||
}, | ||
"gitHead": "b9c19d62d69b6f5f41b75cb79ea20dbca3989dfa" | ||
"gitHead": "3ade9ca405d2449d4948b9e926cea7ad5b3d9c66" | ||
} |
@@ -17,2 +17,2 @@ # Boost Common | ||
[https://milesj.gitbook.io/boost](https://milesj.gitbook.io/boost) | ||
[https://milesj.gitbook.io/boost/common](https://milesj.gitbook.io/boost/common) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
34
230
15947
4
4
3
1
+ Addedjs-yaml@^3.13.1
+ Addedjson5@^2.1.0
+ Addedpretty-ms@^5.0.0
+ Addedargparse@1.0.10(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedjson5@2.2.3(transitive)
+ Addedparse-ms@2.1.0(transitive)
+ Addedpretty-ms@5.1.0(transitive)
+ Addedsprintf-js@1.0.3(transitive)