express-sweet 1.0.13 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,49 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.0.14] - 2022-01-17
6
+ - empty view helper can now check any type. Previously I could only check arrays.
7
+ ```html
8
+ // If the value is an array.
9
+ let value = [5, 6];
10
+ {{empty value}} => false
11
+
12
+ {{#if (empty value)}}
13
+ Hello
14
+ {{/if}}
15
+
16
+ // If the value is a string.
17
+ let value = 'Hello';
18
+ {{empty value}} => false
19
+
20
+ let value = '';
21
+ {{empty value}} => true
22
+
23
+ let value = ' ';
24
+ {{empty value}} => true
25
+ ```
26
+
27
+ - Added not_empty view helper.
28
+ ```html
29
+ // If the value is an array.
30
+ let value = [5, 6];
31
+ {{not_empty value}} => true
32
+
33
+ {{#if (not_empty value)}}
34
+ Hello
35
+ {{/if}}
36
+
37
+ // If the value is a string.
38
+ let value = 'Hello';
39
+ {{not_empty value}} => true
40
+
41
+ let value = '';
42
+ {{not_empty value}} => false
43
+
44
+ let value = ' ';
45
+ {{not_empty value}} => false
46
+ ```
47
+
5
48
  ## [1.0.13] - 2021-12-13
6
49
  ### Fixed
7
50
  - The model's begin method now accepts the transaction option.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs"),a=require("path"),express=require("express"),crypto=require("crypto"),passport=require("passport"),passportLocal=require("passport-local"),buffer=require("buffer"),tty=require("tty"),util=require("util"),net=require("net"),url=require("url"),events=require("events"),i=require("os"),o=require("assert"),sequelize=require("sequelize"),AWS=require("aws-sdk");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var e__default=_interopDefaultLegacy(e),a__default=_interopDefaultLegacy(a),express__default=_interopDefaultLegacy(express),crypto__default=_interopDefaultLegacy(crypto),passport__default=_interopDefaultLegacy(passport),buffer__default=_interopDefaultLegacy(buffer),tty__default=_interopDefaultLegacy(tty),util__default=_interopDefaultLegacy(util),net__default=_interopDefaultLegacy(net),url__default=_interopDefaultLegacy(url),events__default=_interopDefaultLegacy(events),i__default=_interopDefaultLegacy(i),o__default=_interopDefaultLegacy(o),sequelize__default=_interopDefaultLegacy(sequelize),AWS__default=_interopDefaultLegacy(AWS),version="1.0.12";class Global{static mount(){global.APP_DIR=process.cwd(),console.log(`Set ${global.APP_DIR} to global.APP_DIR`)}}function log$2(e){console.log(`[dotenv][DEBUG] ${e}`)}const NEWLINE="\n",RE_INI_KEY_VAL=/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/,RE_NEWLINES=/\\n/g,NEWLINES_MATCH=/\n|\r|\r\n/;function parse$4(e,a){const i=Boolean(a&&a.debug),n={};return e.toString().split(NEWLINES_MATCH).forEach((function(e,a){const s=e.match(RE_INI_KEY_VAL);if(null!=s){const e=s[1];let a=s[2]||"";const i=a.length-1,t='"'===a[0]&&'"'===a[i];"'"===a[0]&&"'"===a[i]||t?(a=a.substring(1,i),t&&(a=a.replace(RE_NEWLINES,NEWLINE))):a=a.trim(),n[e]=a}else i&&log$2(`did not match key and value when parsing line ${a+1}: ${e}`)})),n}function config(e){let a=a__default.default.resolve(process.cwd(),".env"),i="utf8",n=!1;e&&(null!=e.path&&(a=e.path),null!=e.encoding&&(i=e.encoding),null!=e.debug&&(n=!0));try{const e=parse$4(e__default.default.readFileSync(a,{encoding:i}),{debug:n});return Object.keys(e).forEach((function(a){Object.prototype.hasOwnProperty.call(process.env,a)?n&&log$2(`"${a}" is already defined in \`process.env\` and will not be overwritten`):process.env[a]=e[a]})),{parsed:e}}catch(e){return{error:e}}}var config_1=config,parse_1$2=parse$4,main={config:config_1,parse:parse_1$2};class Environment{static mount(){if(global.loadedEnv)return void console.log("env is already loaded, so do nothing");const e=this.loadOptions();if(!e.env_path)return;const a=main.parse(e__default.default.readFileSync(e.env_path));for(let e in a)console.log(`Set ${e} in process.env`),process.env[e]=a[e];console.log(`Environment name: ${process.env.NODE_ENV||"undefined"}`),global.loadedEnv=!0}static loadOptions(){const e={env_path:void 0},a=`${process.cwd()}/config/config`;return e__default.default.existsSync(`${a}.js`)?Object.assign(e,require(a).default||require(a)):e}}function cache_busting(e,a){const i=`${a__default.default.join(process.cwd(),"public")}/${e.replace(/^\//,"")}`;if(!e__default.default.existsSync(i))return e;const n=new Date(e__default.default.statSync(i).mtime).getTime();return`${a}/${e.replace(/^\//,"")}?${n}`}var html=Object.freeze({__proto__:null,cache_busting:cache_busting});function json_stringify(e,a=0){return JSON.stringify(e,null,a)}function json_parse(e){return JSON.parse(e)}var object=Object.freeze({__proto__:null,json_stringify:json_stringify,json_parse:json_parse});function replace(e,a,i){return e.replace(a,i)}var string=Object.freeze({__proto__:null,replace:replace});function isObject(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}function eq(e,a){return e===a}function eqw(e,a){return e==a}function neq(e,a){return e!==a}function neqw(e,a){return e!=a}function lt(e,a){return e<a}function lte(e,a){return e<=a}function gt(e,a){return e>a}function gte(e,a){return e>=a}function not(e){return!e}function ifx(e,a,i){return isObject(i)&&"ifx"===i.name&&i.hasOwnProperty("hash")&&(i=""),e?a:i}function empty(e){return!Array.isArray(e)||0===e.length}function count(e){return!!Array.isArray(e)&&e.length}function and(...e){isObject(e[e.length-1])&&e.pop();for(let a of e)if(!a)return!1;return!0}function or(...e){isObject(e[e.length-1])&&e.pop();for(let a of e)if(a)return!0;return!1}function coalesce(...e){isObject(e[e.length-1])&&e.pop();for(let a of e)if(a)return a;return e.pop()}function includes(e,a,i=!0){if(!Array.isArray(e)||0===e.length)return!1;for(let n of e)if(i&&n===a||!i&&n==a)return!0;return!1}var comparison=Object.freeze({__proto__:null,eq:eq,eqw:eqw,neq:neq,neqw:neqw,lt:lt,lte:lte,gt:gt,gte:gte,not:not,ifx:ifx,empty:empty,count:count,and:and,or:or,coalesce:coalesce,includes:includes}),helpers=Object.freeze({__proto__:null,html:html,object:object,string:string,comparison:comparison});class View{static mount(e){const a=this.loadOptions();console.log(`Set view directory to ${a.views_dir}`),console.log(`Set partials directory to ${a.partials_dir}`),console.log(`Set layouts directory to ${a.layouts_dir}`),console.log(`The default layout is ${a.default_layout}`),console.log(`The extension of the view file is ${a.extension}`);const i=require("express-hbs");for(let[e,a]of Object.entries(helpers))for(let[e,n]of Object.entries(a))console.log(`Add ${e} to handlebars helper`),i.registerHelper(e,n);e.engine("hbs",i.express4({partialsDir:a.partials_dir,layoutsDir:a.layouts_dir,defaultLayout:a.default_layout,extname:a.extension})),e.set("view engine","hbs"),e.set("views",a.views_dir)}static loadOptions(){const e={views_dir:a__default.default.join(process.cwd(),"views"),partials_dir:a__default.default.join(process.cwd(),"views/partials"),layouts_dir:a__default.default.join(process.cwd(),"views/layout"),default_layout:a__default.default.join(process.cwd(),"views/layout/default.hbs"),extension:".hbs"},a=`${process.cwd()}/config/view`;return e__default.default.existsSync(`${a}.js`)?Object.assign(e,require(a).default||require(a)):e}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs"),a=require("path"),express=require("express"),crypto=require("crypto"),passport=require("passport"),passportLocal=require("passport-local"),buffer=require("buffer"),tty=require("tty"),util=require("util"),net=require("net"),url=require("url"),events=require("events"),i=require("os"),o=require("assert"),sequelize=require("sequelize"),AWS=require("aws-sdk");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var e__default=_interopDefaultLegacy(e),a__default=_interopDefaultLegacy(a),express__default=_interopDefaultLegacy(express),crypto__default=_interopDefaultLegacy(crypto),passport__default=_interopDefaultLegacy(passport),buffer__default=_interopDefaultLegacy(buffer),tty__default=_interopDefaultLegacy(tty),util__default=_interopDefaultLegacy(util),net__default=_interopDefaultLegacy(net),url__default=_interopDefaultLegacy(url),events__default=_interopDefaultLegacy(events),i__default=_interopDefaultLegacy(i),o__default=_interopDefaultLegacy(o),sequelize__default=_interopDefaultLegacy(sequelize),AWS__default=_interopDefaultLegacy(AWS),version="1.0.13";class Global{static mount(){global.APP_DIR=process.cwd(),console.log(`Set ${global.APP_DIR} to global.APP_DIR`)}}function log$2(e){console.log(`[dotenv][DEBUG] ${e}`)}const NEWLINE="\n",RE_INI_KEY_VAL=/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/,RE_NEWLINES=/\\n/g,NEWLINES_MATCH=/\n|\r|\r\n/;function parse$4(e,a){const i=Boolean(a&&a.debug),n={};return e.toString().split(NEWLINES_MATCH).forEach((function(e,a){const s=e.match(RE_INI_KEY_VAL);if(null!=s){const e=s[1];let a=s[2]||"";const i=a.length-1,t='"'===a[0]&&'"'===a[i];"'"===a[0]&&"'"===a[i]||t?(a=a.substring(1,i),t&&(a=a.replace(RE_NEWLINES,NEWLINE))):a=a.trim(),n[e]=a}else i&&log$2(`did not match key and value when parsing line ${a+1}: ${e}`)})),n}function config(e){let a=a__default.default.resolve(process.cwd(),".env"),i="utf8",n=!1;e&&(null!=e.path&&(a=e.path),null!=e.encoding&&(i=e.encoding),null!=e.debug&&(n=!0));try{const e=parse$4(e__default.default.readFileSync(a,{encoding:i}),{debug:n});return Object.keys(e).forEach((function(a){Object.prototype.hasOwnProperty.call(process.env,a)?n&&log$2(`"${a}" is already defined in \`process.env\` and will not be overwritten`):process.env[a]=e[a]})),{parsed:e}}catch(e){return{error:e}}}var config_1=config,parse_1$2=parse$4,main={config:config_1,parse:parse_1$2};class Environment{static mount(){if(global.loadedEnv)return void console.log("env is already loaded, so do nothing");const e=this.loadOptions();if(!e.env_path)return;const a=main.parse(e__default.default.readFileSync(e.env_path));for(let e in a)console.log(`Set ${e} in process.env`),process.env[e]=a[e];console.log(`Environment name: ${process.env.NODE_ENV||"undefined"}`),global.loadedEnv=!0}static loadOptions(){const e={env_path:void 0},a=`${process.cwd()}/config/config`;return e__default.default.existsSync(`${a}.js`)?Object.assign(e,require(a).default||require(a)):e}}function cache_busting(e,a){const i=`${a__default.default.join(process.cwd(),"public")}/${e.replace(/^\//,"")}`;if(!e__default.default.existsSync(i))return e;const n=new Date(e__default.default.statSync(i).mtime).getTime();return`${a}/${e.replace(/^\//,"")}?${n}`}var html=Object.freeze({__proto__:null,cache_busting:cache_busting});function json_stringify(e,a=0){return JSON.stringify(e,null,a)}function json_parse(e){return JSON.parse(e)}var object=Object.freeze({__proto__:null,json_stringify:json_stringify,json_parse:json_parse});function replace(e,a,i){return e.replace(a,i)}var string=Object.freeze({__proto__:null,replace:replace});function isObject(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}function eq(e,a){return e===a}function eqw(e,a){return e==a}function neq(e,a){return e!==a}function neqw(e,a){return e!=a}function lt(e,a){return e<a}function lte(e,a){return e<=a}function gt(e,a){return e>a}function gte(e,a){return e>=a}function not(e){return!e}function ifx(e,a,i){return isObject(i)&&"ifx"===i.name&&i.hasOwnProperty("hash")&&(i=""),e?a:i}function empty(e){return"string"==typeof e?e=e.replace(/^[\s ]+|[\s ]+$/g,""):Array.isArray(e)&&0===e.length&&(e=null),!e}function not_empty(e){return"string"==typeof e?e=e.replace(/^[\s ]+|[\s ]+$/g,""):Array.isArray(e)&&0===e.length&&(e=null),!!e}function count(e){return!!Array.isArray(e)&&e.length}function and(...e){isObject(e[e.length-1])&&e.pop();for(let a of e)if(!a)return!1;return!0}function or(...e){isObject(e[e.length-1])&&e.pop();for(let a of e)if(a)return!0;return!1}function coalesce(...e){isObject(e[e.length-1])&&e.pop();for(let a of e)if(a)return a;return e.pop()}function includes(e,a,i=!0){if(!Array.isArray(e)||0===e.length)return!1;for(let n of e)if(i&&n===a||!i&&n==a)return!0;return!1}var comparison=Object.freeze({__proto__:null,eq:eq,eqw:eqw,neq:neq,neqw:neqw,lt:lt,lte:lte,gt:gt,gte:gte,not:not,ifx:ifx,empty:empty,not_empty:not_empty,count:count,and:and,or:or,coalesce:coalesce,includes:includes}),helpers=Object.freeze({__proto__:null,html:html,object:object,string:string,comparison:comparison});class View{static mount(e){const a=this.loadOptions();console.log(`Set view directory to ${a.views_dir}`),console.log(`Set partials directory to ${a.partials_dir}`),console.log(`Set layouts directory to ${a.layouts_dir}`),console.log(`The default layout is ${a.default_layout}`),console.log(`The extension of the view file is ${a.extension}`);const i=require("express-hbs");for(let[e,a]of Object.entries(helpers))for(let[e,n]of Object.entries(a))console.log(`Add ${e} to handlebars helper`),i.registerHelper(e,n);e.engine("hbs",i.express4({partialsDir:a.partials_dir,layoutsDir:a.layouts_dir,defaultLayout:a.default_layout,extname:a.extension})),e.set("view engine","hbs"),e.set("views",a.views_dir)}static loadOptions(){const e={views_dir:a__default.default.join(process.cwd(),"views"),partials_dir:a__default.default.join(process.cwd(),"views/partials"),layouts_dir:a__default.default.join(process.cwd(),"views/layout"),default_layout:a__default.default.join(process.cwd(),"views/layout/default.hbs"),extension:".hbs"},a=`${process.cwd()}/config/view`;return e__default.default.existsSync(`${a}.js`)?Object.assign(e,require(a).default||require(a)):e}}
2
2
  /*!
3
3
  * cookie
4
4
  * Copyright(c) 2012-2014 Roman Shtylman
package/dist/build.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import e from"fs";import a from"path";import express from"express";import crypto from"crypto";import passport from"passport";import{Strategy}from"passport-local";import buffer from"buffer";import tty from"tty";import util from"util";import net from"net";import url from"url";import events from"events";import i from"os";import o from"assert";import sequelize from"sequelize";import AWS from"aws-sdk";var version="1.0.12";class Global{static mount(){global.APP_DIR=process.cwd(),console.log(`Set ${global.APP_DIR} to global.APP_DIR`)}}function log$2(e){console.log(`[dotenv][DEBUG] ${e}`)}const NEWLINE="\n",RE_INI_KEY_VAL=/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/,RE_NEWLINES=/\\n/g,NEWLINES_MATCH=/\n|\r|\r\n/;function parse$4(e,a){const i=Boolean(a&&a.debug),n={};return e.toString().split(NEWLINES_MATCH).forEach((function(e,a){const s=e.match(RE_INI_KEY_VAL);if(null!=s){const e=s[1];let a=s[2]||"";const i=a.length-1,o='"'===a[0]&&'"'===a[i];"'"===a[0]&&"'"===a[i]||o?(a=a.substring(1,i),o&&(a=a.replace(RE_NEWLINES,NEWLINE))):a=a.trim(),n[e]=a}else i&&log$2(`did not match key and value when parsing line ${a+1}: ${e}`)})),n}function config(i){let n=a.resolve(process.cwd(),".env"),s="utf8",o=!1;i&&(null!=i.path&&(n=i.path),null!=i.encoding&&(s=i.encoding),null!=i.debug&&(o=!0));try{const a=parse$4(e.readFileSync(n,{encoding:s}),{debug:o});return Object.keys(a).forEach((function(e){Object.prototype.hasOwnProperty.call(process.env,e)?o&&log$2(`"${e}" is already defined in \`process.env\` and will not be overwritten`):process.env[e]=a[e]})),{parsed:a}}catch(e){return{error:e}}}var config_1=config,parse_1$2=parse$4,main={config:config_1,parse:parse_1$2};class Environment{static mount(){if(global.loadedEnv)return void console.log("env is already loaded, so do nothing");const a=this.loadOptions();if(!a.env_path)return;const i=main.parse(e.readFileSync(a.env_path));for(let e in i)console.log(`Set ${e} in process.env`),process.env[e]=i[e];console.log(`Environment name: ${process.env.NODE_ENV||"undefined"}`),global.loadedEnv=!0}static loadOptions(){const a={env_path:void 0},i=`${process.cwd()}/config/config`;return e.existsSync(`${i}.js`)?Object.assign(a,require(i).default||require(i)):a}}function cache_busting(i,n){const s=`${a.join(process.cwd(),"public")}/${i.replace(/^\//,"")}`;if(!e.existsSync(s))return i;const o=new Date(e.statSync(s).mtime).getTime();return`${n}/${i.replace(/^\//,"")}?${o}`}var html=Object.freeze({__proto__:null,cache_busting:cache_busting});function json_stringify(e,a=0){return JSON.stringify(e,null,a)}function json_parse(e){return JSON.parse(e)}var object=Object.freeze({__proto__:null,json_stringify:json_stringify,json_parse:json_parse});function replace(e,a,i){return e.replace(a,i)}var string=Object.freeze({__proto__:null,replace:replace});function isObject(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}function eq(e,a){return e===a}function eqw(e,a){return e==a}function neq(e,a){return e!==a}function neqw(e,a){return e!=a}function lt(e,a){return e<a}function lte(e,a){return e<=a}function gt(e,a){return e>a}function gte(e,a){return e>=a}function not(e){return!e}function ifx(e,a,i){return isObject(i)&&"ifx"===i.name&&i.hasOwnProperty("hash")&&(i=""),e?a:i}function empty(e){return!Array.isArray(e)||0===e.length}function count(e){return!!Array.isArray(e)&&e.length}function and(...e){isObject(e[e.length-1])&&e.pop();for(let a of e)if(!a)return!1;return!0}function or(...e){isObject(e[e.length-1])&&e.pop();for(let a of e)if(a)return!0;return!1}function coalesce(...e){isObject(e[e.length-1])&&e.pop();for(let a of e)if(a)return a;return e.pop()}function includes(e,a,i=!0){if(!Array.isArray(e)||0===e.length)return!1;for(let n of e)if(i&&n===a||!i&&n==a)return!0;return!1}var comparison=Object.freeze({__proto__:null,eq:eq,eqw:eqw,neq:neq,neqw:neqw,lt:lt,lte:lte,gt:gt,gte:gte,not:not,ifx:ifx,empty:empty,count:count,and:and,or:or,coalesce:coalesce,includes:includes}),helpers=Object.freeze({__proto__:null,html:html,object:object,string:string,comparison:comparison});class View{static mount(e){const a=this.loadOptions();console.log(`Set view directory to ${a.views_dir}`),console.log(`Set partials directory to ${a.partials_dir}`),console.log(`Set layouts directory to ${a.layouts_dir}`),console.log(`The default layout is ${a.default_layout}`),console.log(`The extension of the view file is ${a.extension}`);const i=require("express-hbs");for(let[e,a]of Object.entries(helpers))for(let[e,n]of Object.entries(a))console.log(`Add ${e} to handlebars helper`),i.registerHelper(e,n);e.engine("hbs",i.express4({partialsDir:a.partials_dir,layoutsDir:a.layouts_dir,defaultLayout:a.default_layout,extname:a.extension})),e.set("view engine","hbs"),e.set("views",a.views_dir)}static loadOptions(){const i={views_dir:a.join(process.cwd(),"views"),partials_dir:a.join(process.cwd(),"views/partials"),layouts_dir:a.join(process.cwd(),"views/layout"),default_layout:a.join(process.cwd(),"views/layout/default.hbs"),extension:".hbs"},n=`${process.cwd()}/config/view`;return e.existsSync(`${n}.js`)?Object.assign(i,require(n).default||require(n)):i}}
1
+ import e from"fs";import a from"path";import express from"express";import crypto from"crypto";import passport from"passport";import{Strategy}from"passport-local";import buffer from"buffer";import tty from"tty";import util from"util";import net from"net";import url from"url";import events from"events";import i from"os";import o from"assert";import sequelize from"sequelize";import AWS from"aws-sdk";var version="1.0.13";class Global{static mount(){global.APP_DIR=process.cwd(),console.log(`Set ${global.APP_DIR} to global.APP_DIR`)}}function log$2(e){console.log(`[dotenv][DEBUG] ${e}`)}const NEWLINE="\n",RE_INI_KEY_VAL=/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/,RE_NEWLINES=/\\n/g,NEWLINES_MATCH=/\n|\r|\r\n/;function parse$4(e,a){const i=Boolean(a&&a.debug),n={};return e.toString().split(NEWLINES_MATCH).forEach((function(e,a){const s=e.match(RE_INI_KEY_VAL);if(null!=s){const e=s[1];let a=s[2]||"";const i=a.length-1,o='"'===a[0]&&'"'===a[i];"'"===a[0]&&"'"===a[i]||o?(a=a.substring(1,i),o&&(a=a.replace(RE_NEWLINES,NEWLINE))):a=a.trim(),n[e]=a}else i&&log$2(`did not match key and value when parsing line ${a+1}: ${e}`)})),n}function config(i){let n=a.resolve(process.cwd(),".env"),s="utf8",o=!1;i&&(null!=i.path&&(n=i.path),null!=i.encoding&&(s=i.encoding),null!=i.debug&&(o=!0));try{const a=parse$4(e.readFileSync(n,{encoding:s}),{debug:o});return Object.keys(a).forEach((function(e){Object.prototype.hasOwnProperty.call(process.env,e)?o&&log$2(`"${e}" is already defined in \`process.env\` and will not be overwritten`):process.env[e]=a[e]})),{parsed:a}}catch(e){return{error:e}}}var config_1=config,parse_1$2=parse$4,main={config:config_1,parse:parse_1$2};class Environment{static mount(){if(global.loadedEnv)return void console.log("env is already loaded, so do nothing");const a=this.loadOptions();if(!a.env_path)return;const i=main.parse(e.readFileSync(a.env_path));for(let e in i)console.log(`Set ${e} in process.env`),process.env[e]=i[e];console.log(`Environment name: ${process.env.NODE_ENV||"undefined"}`),global.loadedEnv=!0}static loadOptions(){const a={env_path:void 0},i=`${process.cwd()}/config/config`;return e.existsSync(`${i}.js`)?Object.assign(a,require(i).default||require(i)):a}}function cache_busting(i,n){const s=`${a.join(process.cwd(),"public")}/${i.replace(/^\//,"")}`;if(!e.existsSync(s))return i;const o=new Date(e.statSync(s).mtime).getTime();return`${n}/${i.replace(/^\//,"")}?${o}`}var html=Object.freeze({__proto__:null,cache_busting:cache_busting});function json_stringify(e,a=0){return JSON.stringify(e,null,a)}function json_parse(e){return JSON.parse(e)}var object=Object.freeze({__proto__:null,json_stringify:json_stringify,json_parse:json_parse});function replace(e,a,i){return e.replace(a,i)}var string=Object.freeze({__proto__:null,replace:replace});function isObject(e){return null!=e&&"object"==typeof e&&!1===Array.isArray(e)}function eq(e,a){return e===a}function eqw(e,a){return e==a}function neq(e,a){return e!==a}function neqw(e,a){return e!=a}function lt(e,a){return e<a}function lte(e,a){return e<=a}function gt(e,a){return e>a}function gte(e,a){return e>=a}function not(e){return!e}function ifx(e,a,i){return isObject(i)&&"ifx"===i.name&&i.hasOwnProperty("hash")&&(i=""),e?a:i}function empty(e){return"string"==typeof e?e=e.replace(/^[\s ]+|[\s ]+$/g,""):Array.isArray(e)&&0===e.length&&(e=null),!e}function not_empty(e){return"string"==typeof e?e=e.replace(/^[\s ]+|[\s ]+$/g,""):Array.isArray(e)&&0===e.length&&(e=null),!!e}function count(e){return!!Array.isArray(e)&&e.length}function and(...e){isObject(e[e.length-1])&&e.pop();for(let a of e)if(!a)return!1;return!0}function or(...e){isObject(e[e.length-1])&&e.pop();for(let a of e)if(a)return!0;return!1}function coalesce(...e){isObject(e[e.length-1])&&e.pop();for(let a of e)if(a)return a;return e.pop()}function includes(e,a,i=!0){if(!Array.isArray(e)||0===e.length)return!1;for(let n of e)if(i&&n===a||!i&&n==a)return!0;return!1}var comparison=Object.freeze({__proto__:null,eq:eq,eqw:eqw,neq:neq,neqw:neqw,lt:lt,lte:lte,gt:gt,gte:gte,not:not,ifx:ifx,empty:empty,not_empty:not_empty,count:count,and:and,or:or,coalesce:coalesce,includes:includes}),helpers=Object.freeze({__proto__:null,html:html,object:object,string:string,comparison:comparison});class View{static mount(e){const a=this.loadOptions();console.log(`Set view directory to ${a.views_dir}`),console.log(`Set partials directory to ${a.partials_dir}`),console.log(`Set layouts directory to ${a.layouts_dir}`),console.log(`The default layout is ${a.default_layout}`),console.log(`The extension of the view file is ${a.extension}`);const i=require("express-hbs");for(let[e,a]of Object.entries(helpers))for(let[e,n]of Object.entries(a))console.log(`Add ${e} to handlebars helper`),i.registerHelper(e,n);e.engine("hbs",i.express4({partialsDir:a.partials_dir,layoutsDir:a.layouts_dir,defaultLayout:a.default_layout,extname:a.extension})),e.set("view engine","hbs"),e.set("views",a.views_dir)}static loadOptions(){const i={views_dir:a.join(process.cwd(),"views"),partials_dir:a.join(process.cwd(),"views/partials"),layouts_dir:a.join(process.cwd(),"views/layout"),default_layout:a.join(process.cwd(),"views/layout/default.hbs"),extension:".hbs"},n=`${process.cwd()}/config/view`;return e.existsSync(`${n}.js`)?Object.assign(i,require(n).default||require(n)):i}}
2
2
  /*!
3
3
  * cookie
4
4
  * Copyright(c) 2012-2014 Roman Shtylman
package/docs/index.html CHANGED
@@ -1883,20 +1883,70 @@ Else
1883
1883
  <td class="min-w-150px text-primary fw-bolder">empty</td>
1884
1884
  <td class="min-w-200px w-100">
1885
1885
  <h4 id="view-helper-empty"><code class="method">empty</code></h4>
1886
- <p>Check if an array is empty.</p>
1886
+ <p>
1887
+ Check if it is empty.<br>
1888
+ If the value is an array, returns true if there are no elements.<br>
1889
+ If the value is a string, the leading and trailing spaces are trimmed and then checked.
1890
+ </p>
1887
1891
  <p class="fw-bolder mb-0">Params:</p>
1888
1892
  <ul>
1889
- <li>{any[]} items Array/object to be checked.</li>
1893
+ <li>{any} value Character strings, arrays, objects, etc. to be checked.</li>
1890
1894
  </ul>
1891
1895
  <p class="fw-bolder mb-0">Return:</p>
1892
- <p>{boolean} Returns true if the array is empty, false otherwise.</p>
1896
+ <p>{boolean} Returns true if the value is empty, false otherwise.</p>
1893
1897
  <p class="fw-bolder mb-0">Example:</p>
1894
- <pre class="mb-0"><code class="js">let items = [5, 6];
1895
- {{empty items}} =&gt; false
1898
+ <pre class="mb-0"><code class="js">// If the value is an array.
1899
+ let value = [5, 6];
1900
+ {{empty value}} =&gt; false
1896
1901
 
1897
- {{#if (empty items)}}
1902
+ {{#if (empty value)}}
1898
1903
  Hello
1899
- {{/if}}</code></pre>
1904
+ {{/if}}
1905
+
1906
+ // If the value is a string.
1907
+ let value = &#039;Hello&#039;;
1908
+ {{empty value}} =&gt; false
1909
+
1910
+ let value = &#039;&#039;;
1911
+ {{empty value}} =&gt; true
1912
+
1913
+ let value = &#039; &#039;;
1914
+ {{empty value}} =&gt; true</code></pre>
1915
+ </td>
1916
+ </tr>
1917
+ <tr>
1918
+ <td class="min-w-150px text-primary fw-bolder">not_empty</td>
1919
+ <td class="min-w-200px w-100">
1920
+ <h4 id="view-helper-not_empty"><code class="method">not_empty</code></h4>
1921
+ <p>
1922
+ Check that it is not empty.<br>
1923
+ If the value is an array, returns true if there is an element.<br>
1924
+ If the value is a string, the leading and trailing spaces are trimmed and then checked.
1925
+ </p>
1926
+ <p class="fw-bolder mb-0">Params:</p>
1927
+ <ul>
1928
+ <li>{any} value Character strings, arrays, objects, etc. to be checked.</li>
1929
+ </ul>
1930
+ <p class="fw-bolder mb-0">Return:</p>
1931
+ <p>{boolean} Returns true if the value is not empty, false otherwise.</p>
1932
+ <p class="fw-bolder mb-0">Example:</p>
1933
+ <pre class="mb-0"><code class="js">// If the value is an array.
1934
+ let value = [5, 6];
1935
+ {{not_empty value}} =&gt; true
1936
+
1937
+ {{#if (not_empty value)}}
1938
+ Hello
1939
+ {{/if}}
1940
+
1941
+ // If the value is a string.
1942
+ let value = &#039;Hello&#039;;
1943
+ {{not_empty value}} =&gt; true
1944
+
1945
+ let value = &#039;&#039;;
1946
+ {{not_empty value}} =&gt; false
1947
+
1948
+ let value = &#039; &#039;;
1949
+ {{not_empty value}} =&gt; false</code></pre>
1900
1950
  </td>
1901
1951
  </tr>
1902
1952
  <tr>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-sweet",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Extend Express functionality with Express Sweet and start developing fast, minimal web applications.",
5
5
  "main": "dist/build.common.js",
6
6
  "module": "dist/build.esm.js",
@@ -153,20 +153,61 @@ export declare function not(expression: any): boolean;
153
153
  */
154
154
  export declare function ifx(condition: boolean, value1: any, value2: any): any;
155
155
  /**
156
- * Check if an array is empty.
156
+ * Check if it is empty.
157
+ * If the value is an array, returns true if there are no elements.
158
+ * If the value is a string, the leading and trailing spaces are trimmed and then checked.
157
159
  *
158
160
  * @example
159
- * let items = [5, 6];
160
- * {{empty items}} => false
161
+ * // If the value is an array.
162
+ * let value = [5, 6];
163
+ * {{empty value}} => false
161
164
  *
162
- * {{#if (empty items)}}
165
+ * {{#if (empty value)}}
163
166
  * Hello
164
167
  * {{/if}}
165
168
  *
166
- * @param {any[]} items Array/object to be checked.
167
- * @returns {boolean} Returns true if the array is empty, false otherwise.
169
+ * // If the value is a string.
170
+ * let value = 'Hello';
171
+ * {{empty value}} => false
172
+ *
173
+ * let value = '';
174
+ * {{empty value}} => true
175
+ *
176
+ * let value = ' ';
177
+ * {{empty value}} => true
178
+ *
179
+ * @param {any} value Character strings, arrays, objects, etc. to be checked.
180
+ * @returns {boolean} Returns true if the value is empty, false otherwise.
181
+ */
182
+ export declare function empty(value: any): boolean;
183
+ /**
184
+ * Check that it is not empty.
185
+ * If the value is an array, returns true if there is an element.
186
+ * If the value is a string, the leading and trailing spaces are trimmed and then checked.
187
+ *
188
+ * @example
189
+ * // If the value is an array.
190
+ * let value = [5, 6];
191
+ * {{not_empty value}} => true
192
+ *
193
+ * {{#if (not_empty value)}}
194
+ * Hello
195
+ * {{/if}}
196
+ *
197
+ * // If the value is a string.
198
+ * let value = 'Hello';
199
+ * {{not_empty value}} => true
200
+ *
201
+ * let value = '';
202
+ * {{not_empty value}} => false
203
+ *
204
+ * let value = ' ';
205
+ * {{not_empty value}} => false
206
+ *
207
+ * @param {any} value Character strings, arrays, objects, etc. to be checked.
208
+ * @returns {boolean} Returns true if the value is not empty, false otherwise.
168
209
  */
169
- export declare function empty(items: any[]): boolean;
210
+ export declare function not_empty(value: any): boolean;
170
211
  /**
171
212
  * Determine the length of an array.
172
213
  *