janja 0.0.0 → 1.0.0

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/dist/index.cjs.js CHANGED
@@ -17,7 +17,10 @@ function highlightSource(message, source, ranges) {
17
17
  let cursor = 0;
18
18
  let caretLinesCount = 0;
19
19
  lines.forEach((line, index) => {
20
- output.push(`${`${`${index + 1}: `.padStart(indentWidth, ' ')}`}${line}`);
20
+ if (!line) {
21
+ return;
22
+ }
23
+ output.push(`${`${index + 1}: `.padStart(indentWidth, ' ')}${line}`);
21
24
  ranges.forEach((tag) => {
22
25
  if (tag.start < cursor) {
23
26
  ranges.splice(ranges.indexOf(tag), 1);
@@ -326,66 +329,6 @@ class Compiler {
326
329
  }
327
330
  }
328
331
 
329
- const hasOwn = Object.prototype.hasOwnProperty;
330
- function translate(translations = {}, key, params = {}) {
331
- return (hasOwn.call(translations, key) ? translations[key] : key).replace(/\{(.+?)\}/g, (_, name) => (hasOwn.call(params, name) ? params[name] : _));
332
- }
333
-
334
- const monthNames = [
335
- 'January',
336
- 'February',
337
- 'March',
338
- 'April',
339
- 'May',
340
- 'June',
341
- 'July',
342
- 'August',
343
- 'September',
344
- 'October',
345
- 'November',
346
- 'December',
347
- ];
348
- const shortMonthNames = [
349
- 'Jan',
350
- 'Feb',
351
- 'Mar',
352
- 'Apr',
353
- 'May',
354
- 'Jun',
355
- 'Jul',
356
- 'Aug',
357
- 'Sep',
358
- 'Oct',
359
- 'Nov',
360
- 'Dec',
361
- ];
362
- const dayNames = [
363
- 'Sunday',
364
- 'Monday',
365
- 'Tuesday',
366
- 'Wednesday',
367
- 'Thursday',
368
- 'Friday',
369
- 'Saturday',
370
- ];
371
- const shortDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
372
- const o = {
373
- y: d => `${d.getUTCFullYear()}`,
374
- M: (d, len) => `${d.getUTCMonth() + 1}`.padStart(len, '0'),
375
- N: (d, len, translations) => translate(translations, (len > 1 ? monthNames : shortMonthNames)[d.getUTCMonth()]),
376
- d: (d, len) => `${d.getUTCDate()}`.padStart(len, '0'),
377
- h: (d, len) => `${d.getUTCHours()}`.padStart(len, '0'),
378
- m: (d, len) => `${d.getUTCMinutes()}`.padStart(len, '0'),
379
- s: (d, len) => `${d.getUTCSeconds()}`.padStart(len, '0'),
380
- D: (d, len, translations) => translate(translations, (len > 1 ? dayNames : shortDayNames)[d.getUTCDay()]),
381
- };
382
- function formatDatetime(translations = {}, value = 0, format) {
383
- const d = new Date(value);
384
- return format.replace(/y+|M+|N+|d+|h+|m+|s+|D+/g, (str) => {
385
- return o[str[0]](d, str.length, translations);
386
- });
387
- }
388
-
389
332
  class Safe extends String {
390
333
  constructor(value) {
391
334
  super(`${value}`);
@@ -416,8 +359,8 @@ function ceil(value = 0) {
416
359
  function compact(value = []) {
417
360
  return value.filter(v => v != null);
418
361
  }
419
- function date(value = 0, format = 'yy-MM-dd hh:mm') {
420
- return formatDatetime(this.translations, value, format);
362
+ function div(value = 0, divisor = 1) {
363
+ return value / divisor;
421
364
  }
422
365
  function entries(value = {}) {
423
366
  return Object.entries(value);
@@ -470,8 +413,8 @@ function max(value = 0, ...values) {
470
413
  function min(value = 0, ...values) {
471
414
  return Math.min(value, ...values);
472
415
  }
473
- function minus(value = 0, minuend = 0) {
474
- return value - minuend;
416
+ function mul(value = 0, multiplier = 1) {
417
+ return value * multiplier;
475
418
  }
476
419
  function odd(value = 0) {
477
420
  return +value % 2 === 1;
@@ -503,15 +446,12 @@ function sort(value = []) {
503
446
  function split(value = '', separator = '') {
504
447
  return value.split(separator);
505
448
  }
449
+ function sub(value = 0, subtrahend = 0) {
450
+ return value - subtrahend;
451
+ }
506
452
  function sum(value = []) {
507
453
  return value.reduce((a, b) => a + b, 0);
508
454
  }
509
- function t(value, params) {
510
- return translate(this.translations, value, params);
511
- }
512
- function time(value = 0, format = 'hh:mm') {
513
- return formatDatetime(this.translations, value, format);
514
- }
515
455
  function trim(value = '') {
516
456
  return value.trim();
517
457
  }
@@ -543,7 +483,7 @@ var filters = /*#__PURE__*/Object.freeze({
543
483
  capitalize: capitalize,
544
484
  ceil: ceil,
545
485
  compact: compact,
546
- date: date,
486
+ div: div,
547
487
  entries: entries,
548
488
  escape: escape,
549
489
  even: even,
@@ -560,7 +500,7 @@ var filters = /*#__PURE__*/Object.freeze({
560
500
  map: map,
561
501
  max: max,
562
502
  min: min,
563
- minus: minus,
503
+ mul: mul,
564
504
  odd: odd,
565
505
  omit: omit,
566
506
  pick: pick,
@@ -571,9 +511,8 @@ var filters = /*#__PURE__*/Object.freeze({
571
511
  slice: slice,
572
512
  sort: sort,
573
513
  split: split,
514
+ sub: sub,
574
515
  sum: sum,
575
- t: t,
576
- time: time,
577
516
  trim: trim,
578
517
  truncate: truncate,
579
518
  unique: unique,
package/dist/index.esm.js CHANGED
@@ -15,7 +15,10 @@ function highlightSource(message, source, ranges) {
15
15
  let cursor = 0;
16
16
  let caretLinesCount = 0;
17
17
  lines.forEach((line, index) => {
18
- output.push(`${`${`${index + 1}: `.padStart(indentWidth, ' ')}`}${line}`);
18
+ if (!line) {
19
+ return;
20
+ }
21
+ output.push(`${`${index + 1}: `.padStart(indentWidth, ' ')}${line}`);
19
22
  ranges.forEach((tag) => {
20
23
  if (tag.start < cursor) {
21
24
  ranges.splice(ranges.indexOf(tag), 1);
@@ -324,66 +327,6 @@ class Compiler {
324
327
  }
325
328
  }
326
329
 
327
- const hasOwn = Object.prototype.hasOwnProperty;
328
- function translate(translations = {}, key, params = {}) {
329
- return (hasOwn.call(translations, key) ? translations[key] : key).replace(/\{(.+?)\}/g, (_, name) => (hasOwn.call(params, name) ? params[name] : _));
330
- }
331
-
332
- const monthNames = [
333
- 'January',
334
- 'February',
335
- 'March',
336
- 'April',
337
- 'May',
338
- 'June',
339
- 'July',
340
- 'August',
341
- 'September',
342
- 'October',
343
- 'November',
344
- 'December',
345
- ];
346
- const shortMonthNames = [
347
- 'Jan',
348
- 'Feb',
349
- 'Mar',
350
- 'Apr',
351
- 'May',
352
- 'Jun',
353
- 'Jul',
354
- 'Aug',
355
- 'Sep',
356
- 'Oct',
357
- 'Nov',
358
- 'Dec',
359
- ];
360
- const dayNames = [
361
- 'Sunday',
362
- 'Monday',
363
- 'Tuesday',
364
- 'Wednesday',
365
- 'Thursday',
366
- 'Friday',
367
- 'Saturday',
368
- ];
369
- const shortDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
370
- const o = {
371
- y: d => `${d.getUTCFullYear()}`,
372
- M: (d, len) => `${d.getUTCMonth() + 1}`.padStart(len, '0'),
373
- N: (d, len, translations) => translate(translations, (len > 1 ? monthNames : shortMonthNames)[d.getUTCMonth()]),
374
- d: (d, len) => `${d.getUTCDate()}`.padStart(len, '0'),
375
- h: (d, len) => `${d.getUTCHours()}`.padStart(len, '0'),
376
- m: (d, len) => `${d.getUTCMinutes()}`.padStart(len, '0'),
377
- s: (d, len) => `${d.getUTCSeconds()}`.padStart(len, '0'),
378
- D: (d, len, translations) => translate(translations, (len > 1 ? dayNames : shortDayNames)[d.getUTCDay()]),
379
- };
380
- function formatDatetime(translations = {}, value = 0, format) {
381
- const d = new Date(value);
382
- return format.replace(/y+|M+|N+|d+|h+|m+|s+|D+/g, (str) => {
383
- return o[str[0]](d, str.length, translations);
384
- });
385
- }
386
-
387
330
  class Safe extends String {
388
331
  constructor(value) {
389
332
  super(`${value}`);
@@ -414,8 +357,8 @@ function ceil(value = 0) {
414
357
  function compact(value = []) {
415
358
  return value.filter(v => v != null);
416
359
  }
417
- function date(value = 0, format = 'yy-MM-dd hh:mm') {
418
- return formatDatetime(this.translations, value, format);
360
+ function div(value = 0, divisor = 1) {
361
+ return value / divisor;
419
362
  }
420
363
  function entries(value = {}) {
421
364
  return Object.entries(value);
@@ -468,8 +411,8 @@ function max(value = 0, ...values) {
468
411
  function min(value = 0, ...values) {
469
412
  return Math.min(value, ...values);
470
413
  }
471
- function minus(value = 0, minuend = 0) {
472
- return value - minuend;
414
+ function mul(value = 0, multiplier = 1) {
415
+ return value * multiplier;
473
416
  }
474
417
  function odd(value = 0) {
475
418
  return +value % 2 === 1;
@@ -501,15 +444,12 @@ function sort(value = []) {
501
444
  function split(value = '', separator = '') {
502
445
  return value.split(separator);
503
446
  }
447
+ function sub(value = 0, subtrahend = 0) {
448
+ return value - subtrahend;
449
+ }
504
450
  function sum(value = []) {
505
451
  return value.reduce((a, b) => a + b, 0);
506
452
  }
507
- function t(value, params) {
508
- return translate(this.translations, value, params);
509
- }
510
- function time(value = 0, format = 'hh:mm') {
511
- return formatDatetime(this.translations, value, format);
512
- }
513
453
  function trim(value = '') {
514
454
  return value.trim();
515
455
  }
@@ -541,7 +481,7 @@ var filters = /*#__PURE__*/Object.freeze({
541
481
  capitalize: capitalize,
542
482
  ceil: ceil,
543
483
  compact: compact,
544
- date: date,
484
+ div: div,
545
485
  entries: entries,
546
486
  escape: escape,
547
487
  even: even,
@@ -558,7 +498,7 @@ var filters = /*#__PURE__*/Object.freeze({
558
498
  map: map,
559
499
  max: max,
560
500
  min: min,
561
- minus: minus,
501
+ mul: mul,
562
502
  odd: odd,
563
503
  omit: omit,
564
504
  pick: pick,
@@ -569,9 +509,8 @@ var filters = /*#__PURE__*/Object.freeze({
569
509
  slice: slice,
570
510
  sort: sort,
571
511
  split: split,
512
+ sub: sub,
572
513
  sum: sum,
573
- t: t,
574
- time: time,
575
514
  trim: trim,
576
515
  truncate: truncate,
577
516
  unique: unique,
package/dist/index.js CHANGED
@@ -18,7 +18,10 @@
18
18
  let cursor = 0;
19
19
  let caretLinesCount = 0;
20
20
  lines.forEach((line, index) => {
21
- output.push(`${`${`${index + 1}: `.padStart(indentWidth, ' ')}`}${line}`);
21
+ if (!line) {
22
+ return;
23
+ }
24
+ output.push(`${`${index + 1}: `.padStart(indentWidth, ' ')}${line}`);
22
25
  ranges.forEach((tag) => {
23
26
  if (tag.start < cursor) {
24
27
  ranges.splice(ranges.indexOf(tag), 1);
@@ -327,66 +330,6 @@ ${output
327
330
  }
328
331
  }
329
332
 
330
- const hasOwn = Object.prototype.hasOwnProperty;
331
- function translate(translations = {}, key, params = {}) {
332
- return (hasOwn.call(translations, key) ? translations[key] : key).replace(/\{(.+?)\}/g, (_, name) => (hasOwn.call(params, name) ? params[name] : _));
333
- }
334
-
335
- const monthNames = [
336
- 'January',
337
- 'February',
338
- 'March',
339
- 'April',
340
- 'May',
341
- 'June',
342
- 'July',
343
- 'August',
344
- 'September',
345
- 'October',
346
- 'November',
347
- 'December',
348
- ];
349
- const shortMonthNames = [
350
- 'Jan',
351
- 'Feb',
352
- 'Mar',
353
- 'Apr',
354
- 'May',
355
- 'Jun',
356
- 'Jul',
357
- 'Aug',
358
- 'Sep',
359
- 'Oct',
360
- 'Nov',
361
- 'Dec',
362
- ];
363
- const dayNames = [
364
- 'Sunday',
365
- 'Monday',
366
- 'Tuesday',
367
- 'Wednesday',
368
- 'Thursday',
369
- 'Friday',
370
- 'Saturday',
371
- ];
372
- const shortDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
373
- const o = {
374
- y: d => `${d.getUTCFullYear()}`,
375
- M: (d, len) => `${d.getUTCMonth() + 1}`.padStart(len, '0'),
376
- N: (d, len, translations) => translate(translations, (len > 1 ? monthNames : shortMonthNames)[d.getUTCMonth()]),
377
- d: (d, len) => `${d.getUTCDate()}`.padStart(len, '0'),
378
- h: (d, len) => `${d.getUTCHours()}`.padStart(len, '0'),
379
- m: (d, len) => `${d.getUTCMinutes()}`.padStart(len, '0'),
380
- s: (d, len) => `${d.getUTCSeconds()}`.padStart(len, '0'),
381
- D: (d, len, translations) => translate(translations, (len > 1 ? dayNames : shortDayNames)[d.getUTCDay()]),
382
- };
383
- function formatDatetime(translations = {}, value = 0, format) {
384
- const d = new Date(value);
385
- return format.replace(/y+|M+|N+|d+|h+|m+|s+|D+/g, (str) => {
386
- return o[str[0]](d, str.length, translations);
387
- });
388
- }
389
-
390
333
  class Safe extends String {
391
334
  constructor(value) {
392
335
  super(`${value}`);
@@ -417,8 +360,8 @@ ${output
417
360
  function compact(value = []) {
418
361
  return value.filter(v => v != null);
419
362
  }
420
- function date(value = 0, format = 'yy-MM-dd hh:mm') {
421
- return formatDatetime(this.translations, value, format);
363
+ function div(value = 0, divisor = 1) {
364
+ return value / divisor;
422
365
  }
423
366
  function entries(value = {}) {
424
367
  return Object.entries(value);
@@ -471,8 +414,8 @@ ${output
471
414
  function min(value = 0, ...values) {
472
415
  return Math.min(value, ...values);
473
416
  }
474
- function minus(value = 0, minuend = 0) {
475
- return value - minuend;
417
+ function mul(value = 0, multiplier = 1) {
418
+ return value * multiplier;
476
419
  }
477
420
  function odd(value = 0) {
478
421
  return +value % 2 === 1;
@@ -504,15 +447,12 @@ ${output
504
447
  function split(value = '', separator = '') {
505
448
  return value.split(separator);
506
449
  }
450
+ function sub(value = 0, subtrahend = 0) {
451
+ return value - subtrahend;
452
+ }
507
453
  function sum(value = []) {
508
454
  return value.reduce((a, b) => a + b, 0);
509
455
  }
510
- function t(value, params) {
511
- return translate(this.translations, value, params);
512
- }
513
- function time(value = 0, format = 'hh:mm') {
514
- return formatDatetime(this.translations, value, format);
515
- }
516
456
  function trim(value = '') {
517
457
  return value.trim();
518
458
  }
@@ -544,7 +484,7 @@ ${output
544
484
  capitalize: capitalize,
545
485
  ceil: ceil,
546
486
  compact: compact,
547
- date: date,
487
+ div: div,
548
488
  entries: entries,
549
489
  escape: escape,
550
490
  even: even,
@@ -561,7 +501,7 @@ ${output
561
501
  map: map,
562
502
  max: max,
563
503
  min: min,
564
- minus: minus,
504
+ mul: mul,
565
505
  odd: odd,
566
506
  omit: omit,
567
507
  pick: pick,
@@ -572,9 +512,8 @@ ${output
572
512
  slice: slice,
573
513
  sort: sort,
574
514
  split: split,
515
+ sub: sub,
575
516
  sum: sum,
576
- t: t,
577
- time: time,
578
517
  trim: trim,
579
518
  truncate: truncate,
580
519
  unique: unique,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "janja",
3
3
  "type": "module",
4
- "version": "0.0.0",
4
+ "version": "1.0.0",
5
5
  "packageManager": "yarn@4.9.2",
6
6
  "description": "A simple, fast, lightweight, and extensible template engine for Node.js and browsers.",
7
7
  "license": "MIT",