Releases: losandes/hilaryjs
Adds Resolve Expressions
You can now resolve modules, using expressions:
scope.register({ name: 'one-component', factory: 1 });
scope.register({ name: 'two-component', factory: 2 });
scope.register({ name: 'three', factory: 3 });
scope.resolve(/component/i, function (err, components) {
assert(components[0], 1);
assert(components[1], 2);
});
// OR
const components = scope.resolve(/component/i);
assert(components[0], 1);
assert(components[1], 2);
Adds Dependency Expressions
With this release you can now depend on expressions. When using an expression for a dependency, hilary returns an array of modules that match the expression.
scope.register({ name: 'one-component', factory: 1 });
scope.register({ name: 'two-component', factory: 2 });
scope.register({ name: 'three', factory: 3 });
scope.register({
name: 'all-components',
dependencies: [/component/i],
factory: function (components) {
assert(components[0], 1);
assert(components[1], 2);
}
});
Fixes Resolve When Modules Throw Errors
This release fixes a bug that was caused by modules that threw Errors. Instead of partially resolving modules that depend on modules that throw errors, hilary now stops resolution, logs the event at the error level (50), and returns a hilary exception with information that is useful for debugging.
hilary v5! A complete rewrite of hilary, with support for ES6
This version is NOT backwards compatible, HOWEVER, your modules should still work. There are many enhancements, and there are significant changes to bootstrapping your app.
A sampling of changes include:
- Registering ES6 Classes is now supported
- Registering ES6 Arrow Functions is now supported
- Reducing module members (similar to ES6 import) is now supported
- Boostrapping is way easier (but different - as in breaking changes)
- Modules are registered as singletons by default (that used to be opt-in)
- The syntax is the same for both synchronous and asynchronous execution (no more registerAsync, etc)
- Resolving arrays is no longer supported (it's easier just to use async.js series or parallel)
- The root
hilary
object is now a scope - no construction necessary (you can still create new scopes) - Debugging is much easier, with support for trace-log debugging
- You can inject your own log printer or handler
- Most of the utilities (i.e. Blueprint, is) were moved to polyn, and are no longer found on the root object, or scope context - you can still depend on them, via polyn
Browser Support for module.exports
[Browser Only] You can now use module.exports
syntax to register your modules. Beyond syntax candy, this allows you to decouple your modules from Hilary, making it easier to refactor, or inject global DI behaviors.
You have to add the script: <script src="[PATH]/release/hilary.moduleExports.min.js" />
. Then you can define your modules like this:
module.exports = {
scope: 'myApp',
name: 'myModule',
dependencines: [],
factory: function () {
'use strict';
// do something
}
};
Note: You should ALWAYS have a names scope, like the example above, in addition to the requirements of Hilary's
register
feature.
Improves is.datetime
- Adds
is.date
andis.not.date
as an alias tois.datetime
andis.not.datetime
- is.datetime now checks to see if the date is valid, in addition to ensuring that the type is
[object Date]
Blueprint Custom Validation Feature
When using Custom Validation with Blueprints, the validate
function now receives three arguments (this change is backwards compatible). The first two arguments are the same as before. The new, third argument is the implementation itself, which allows you to perform cross-property validation:
// > omitted for brevity
validate: function (meaningOfLife, errorArray, superComputer) {
if (superComputer.isOn && meaningOfLife !== 42) {
errorArray.push('Sorry, that is not the answer to the meaning of life, the universe and everything');
}
}
// < omitted for brevity
Nullable Blueprint Properties
This release adds the ability to make Blueprint properties nullable, so they can be validated when a value exists, but a value is not required to satisfy validity.
Read more about it in the Blueprint wiki.
Consistent Error Emitting
When errors are emitted, Hilary attempts to transform the error message into a JavaScript Error
, if it is not already, so less-to-no logic should be necessary in your error handlers.
PipelineEvent Removal
Hilary 4.1 introduces 2 new features: