Skip to content

Commit

Permalink
new types, new library methods, fix docs, version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
realtux committed Sep 25, 2024
1 parent 842d8f2 commit e213df2
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ declare module '@exajs/core/system/sequelize' {

declare module '@exajs/core/util' {
import json from '#exa/util/json.js';

export { json };
import string from '#exa/util/string.js';
export { json, string };
}
2 changes: 1 addition & 1 deletion lib/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let config = {
/**
* internal config
*/
version: '0.0.13',
version: '0.0.14',

paths: {
root: '',
Expand Down
6 changes: 5 additions & 1 deletion lib/util/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import json from '#exa/util/json.js';
import string from '#exa/util/string.js';

export { json };
export {
json,
string,
};
40 changes: 40 additions & 0 deletions lib/util/string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export default new class {

ucwords(string) {
return (string + '')
.toLowerCase()
.replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g, result => {
return result.toUpperCase();
});
}

to_slug(string) {
return (string + '')
.toLowerCase()
.trim()
.replace(/[^a-z0-9 ]+/g, '')
.replace(/ +/g, '-');
}

to_currency(amount) {
if (!amount || isNaN(amount)) {
return '$0.00';
}

let formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
});

return formatter.format(amount);
}

strip_html(str) {
if (typeof str !== 'string') {
return str;
}

return str.replace(/<(?:.|\n)*?>/gm, '');
}

};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@exajs/core",
"type": "module",
"author": "Brian Seymour <@realtux>",
"version": "0.0.13",
"version": "0.0.14",
"description": "modern opinionated node.js framework",
"license": "MIT",
"homepage": "https://github.com/realtux/exa",
Expand Down
1 change: 1 addition & 0 deletions var/template/.env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
EXAENV=development

# optionally add values here and overwrite values in config/master.js
DATABASE_HOST=mysql
DATABASE_PORT=3306
DATABASE_USERNAME=root
Expand Down

0 comments on commit e213df2

Please sign in to comment.