@indra.ai/deva 1.2.21 → 1.2.23
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/config.json +9 -4
- package/index.js +73 -59
- package/package.json +1 -1
package/config.json
CHANGED
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"memory": "💭 Memory",
|
|
106
106
|
"response": "✍️ Response",
|
|
107
107
|
"invalid": "👎 INVALID!",
|
|
108
|
+
"valid": "👍 VALID!",
|
|
108
109
|
"abort": "💔 ABORT!",
|
|
109
110
|
"error": "❌ ERROR!",
|
|
110
111
|
"help": "💙 Help"
|
|
@@ -122,6 +123,7 @@
|
|
|
122
123
|
"unload": "🥡 Unload",
|
|
123
124
|
"done": "✅ Done",
|
|
124
125
|
"question": "🙋 Question",
|
|
126
|
+
"talk": "📢 Talk",
|
|
125
127
|
"context": "Context",
|
|
126
128
|
"prompt": "🐚 Prompt",
|
|
127
129
|
"issue": "🎫 Issue",
|
|
@@ -140,6 +142,8 @@
|
|
|
140
142
|
"write": "️📝 Write",
|
|
141
143
|
"set": "🍽️ Set",
|
|
142
144
|
"get": "🤔 Get",
|
|
145
|
+
"send": "🚀 Send",
|
|
146
|
+
"receive": "🥅 Receive",
|
|
143
147
|
"return": "🎁 Return",
|
|
144
148
|
"resolve": "⛵️ Resolve",
|
|
145
149
|
"reject": "❌ Reject",
|
|
@@ -183,10 +187,11 @@
|
|
|
183
187
|
"decipher": "🔓 Decipher",
|
|
184
188
|
"promp": "🪵 Prompt",
|
|
185
189
|
"getToday": "📆 Get Today",
|
|
186
|
-
"formatDate": "📅 Date",
|
|
187
|
-
"formatTime": "🕰️ Time",
|
|
188
|
-
"formatCurrency": "💰 Currency",
|
|
189
|
-
"formatPercent": "
|
|
190
|
+
"formatDate": "📅 Format Date",
|
|
191
|
+
"formatTime": "🕰️ Format Time",
|
|
192
|
+
"formatCurrency": "💰 Format Currency",
|
|
193
|
+
"formatPercent": "% Format Percent",
|
|
194
|
+
"formatNumbert": "# Format Number",
|
|
190
195
|
"trimWords": "🙊 Trim Words",
|
|
191
196
|
"dupes": "📋 Duplicates",
|
|
192
197
|
"info": "💁♂️ Info",
|
package/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const config = require('./config.json').DATA // load the deva core configuration
|
|
|
11
11
|
class Deva {
|
|
12
12
|
constructor(opts) {
|
|
13
13
|
opts = opts || {}; // set opts to provided opts or an empty object.
|
|
14
|
-
this._id = randomUUID(); // the unique id assigned to the agent at load
|
|
14
|
+
this._id = opts.id || randomUUID(); // the unique id assigned to the agent at load
|
|
15
15
|
this._info = opts.info || false; // the deva information from the package file.
|
|
16
16
|
this._config = opts.config || {}; // local Config Object
|
|
17
17
|
this._agent = opts.agent || false; // Agent profile object
|
|
@@ -35,7 +35,7 @@ class Deva {
|
|
|
35
35
|
this.maxListeners = opts.maxListenners || 0; // set the local maxListeners
|
|
36
36
|
|
|
37
37
|
// prevent overwriting existing functions and variables with same name
|
|
38
|
-
for (
|
|
38
|
+
for (const opt in opts) {
|
|
39
39
|
if (!this[opt] || !this[`_${opt}`]) this[opt] = opts[opt];
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -215,11 +215,12 @@ class Deva {
|
|
|
215
215
|
***************/
|
|
216
216
|
Security() {
|
|
217
217
|
this.zone('security');
|
|
218
|
+
this.action('Security'); // set action to Security
|
|
218
219
|
const _cl = this.client(); // set local copy of client data
|
|
219
220
|
try {
|
|
220
221
|
if (!_cl.features.security) return this.Support(); // if no security feature goto Support
|
|
221
222
|
else {
|
|
222
|
-
this.state('
|
|
223
|
+
this.state('set', 'Security');
|
|
223
224
|
const {id, profile, features} = _cl; // make a copy the clinet data.
|
|
224
225
|
const {security} = features; // make a copy the clinet data.
|
|
225
226
|
this._security = { // set this_security with data
|
|
@@ -233,10 +234,11 @@ class Deva {
|
|
|
233
234
|
personal: security.devas[this._agent.key], // Client personal features and rules.
|
|
234
235
|
};
|
|
235
236
|
delete this._client.features.security; // make a copy the clinet data.
|
|
236
|
-
this.
|
|
237
|
+
this.state('resolve', 'Support');
|
|
237
238
|
return this.Support(); // goto Support when done with Security
|
|
238
239
|
}
|
|
239
240
|
} catch (e) {
|
|
241
|
+
this.state('reject', 'Support');
|
|
240
242
|
return this.error(e); // run error handling if an error is caught
|
|
241
243
|
}
|
|
242
244
|
}
|
|
@@ -250,11 +252,12 @@ class Deva {
|
|
|
250
252
|
***************/
|
|
251
253
|
Support() {
|
|
252
254
|
this.zone('support');
|
|
255
|
+
this.action('Support');
|
|
253
256
|
const _cl = this.client(); // set the local client variable
|
|
254
257
|
try {
|
|
255
258
|
if (!_cl.features.support) return this.Services() // move to Services if no support feature
|
|
256
259
|
else {
|
|
257
|
-
this.state('
|
|
260
|
+
this.state('set', 'Support');
|
|
258
261
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
259
262
|
const {support} = features; // set support from features const
|
|
260
263
|
this._support = { // set this_support with data
|
|
@@ -266,10 +269,11 @@ class Deva {
|
|
|
266
269
|
personal: support.devas[this._agent.key], // Client personalSecurity features and rules.
|
|
267
270
|
};
|
|
268
271
|
delete this._client.features.support; // delete the support key from the client
|
|
269
|
-
this.
|
|
272
|
+
this.state('resolve', 'Services');
|
|
270
273
|
return this.Services(); // when done move to Services
|
|
271
274
|
}
|
|
272
275
|
} catch (e) {
|
|
276
|
+
this.state('reject', 'Services');
|
|
273
277
|
return this.error(e); // run error handling if an error is caught
|
|
274
278
|
}
|
|
275
279
|
}
|
|
@@ -283,11 +287,12 @@ class Deva {
|
|
|
283
287
|
***************/
|
|
284
288
|
Services() {
|
|
285
289
|
this.zone('services')
|
|
290
|
+
this.action('Services');
|
|
286
291
|
const _cl = this.client(); // set local client
|
|
287
292
|
try {
|
|
288
293
|
if (!_cl.features.services) return this.Done(); // move to Done if no Services feature
|
|
289
294
|
else {
|
|
290
|
-
this.state('
|
|
295
|
+
this.state('set', 'Services');
|
|
291
296
|
const {id, features, profile} = _cl; // set the local consts from client copy
|
|
292
297
|
const {services} = features; // set services from features const
|
|
293
298
|
this._services = { // set this_services with data
|
|
@@ -299,10 +304,11 @@ class Deva {
|
|
|
299
304
|
personal: services.devas[this._agent.key], // Client personal features and rules.
|
|
300
305
|
};
|
|
301
306
|
delete this._client.features.services; // delete the services key for isolation
|
|
302
|
-
this.
|
|
307
|
+
this.state('resolve', 'Services');
|
|
303
308
|
return this.Done(); // go to Done
|
|
304
309
|
}
|
|
305
310
|
} catch (e) {
|
|
311
|
+
this.state('reject', 'Services');
|
|
306
312
|
return this.error(e); // run error handling if an error is caught
|
|
307
313
|
}
|
|
308
314
|
}
|
|
@@ -313,14 +319,15 @@ class Deva {
|
|
|
313
319
|
describe: The end of the workflow Client Feature Workflow
|
|
314
320
|
***************/
|
|
315
321
|
Done(client) {
|
|
316
|
-
this.state('done');
|
|
317
322
|
this.action('done');
|
|
318
323
|
return new Promise((resolve, reject) => {
|
|
319
324
|
try {
|
|
325
|
+
this.state('done');
|
|
320
326
|
delete this._client.features; // delete the features key when done.
|
|
321
|
-
this.state('
|
|
327
|
+
this.state('resolve', 'done');
|
|
322
328
|
return resolve(client); // resolve an empty pr
|
|
323
329
|
} catch (e) {
|
|
330
|
+
this.state('reject', 'done');
|
|
324
331
|
return this.error(e, false, reject);
|
|
325
332
|
}
|
|
326
333
|
});
|
|
@@ -388,7 +395,8 @@ class Deva {
|
|
|
388
395
|
question(TEXT=false, DATA=false) {
|
|
389
396
|
// check the active status
|
|
390
397
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
391
|
-
this.zone('question');
|
|
398
|
+
this.zone('question');
|
|
399
|
+
|
|
392
400
|
const id = this.uid(); // generate a unique id for transport.
|
|
393
401
|
const t_split = TEXT.split(' '); // split the text on spaces to get words.
|
|
394
402
|
const data = DATA; // set the DATA to data
|
|
@@ -415,11 +423,8 @@ class Deva {
|
|
|
415
423
|
return new Promise((resolve, reject) => {
|
|
416
424
|
// resolve with the no text message if the client says nothing.
|
|
417
425
|
if (!TEXT) return this.finish(this._messages.notext, resolve);
|
|
418
|
-
let _action = 'question'; // set the initial _action to question.
|
|
419
|
-
this.state('question'); // set the state to question
|
|
420
426
|
try { // try to answer the question
|
|
421
427
|
if (isAsk) { // determine if hte question isAsk
|
|
422
|
-
_action = 'question_ask';
|
|
423
428
|
// if:isAsk split the agent key and remove first command character
|
|
424
429
|
key = t_split[0].substring(1);
|
|
425
430
|
//if:isAsk use text split index 1 as the parameter block
|
|
@@ -429,7 +434,6 @@ class Deva {
|
|
|
429
434
|
this.state('ask', `${key} ${method}`);
|
|
430
435
|
}
|
|
431
436
|
else if (isCmd) { // determine if the question is a command
|
|
432
|
-
_action = 'question_cmd';
|
|
433
437
|
//if:isCmd use text split index 1 as the parameter block
|
|
434
438
|
params = t_split[0] ? t_split[0].split(':').slice(1) : false;
|
|
435
439
|
method = t_split[0].substring(1); // if:isCmd use the 0 index as the command
|
|
@@ -437,41 +441,44 @@ class Deva {
|
|
|
437
441
|
this.state('cmd', method); // set the state to cmd.
|
|
438
442
|
}
|
|
439
443
|
|
|
444
|
+
this.state('set', `question:${method}`)
|
|
440
445
|
packet.q = { // build packet.q container
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
446
|
+
id: this.uid(), // set the transport id for the question.
|
|
447
|
+
agent: this.agent(), // set the agent
|
|
448
|
+
client: this.client(), // set the client
|
|
449
|
+
meta: { // build the meta container
|
|
450
|
+
key, // set the key variable
|
|
451
|
+
method, // set method to track function use
|
|
452
|
+
params, // set any params that are associated
|
|
453
|
+
},
|
|
454
|
+
text, // set the text for the packet.
|
|
455
|
+
data, // set the data object
|
|
456
|
+
created: Date.now(), // timestamp the question
|
|
452
457
|
}
|
|
453
458
|
|
|
454
459
|
// hash the question
|
|
455
460
|
packet.q.meta.hash = this.hash(packet.q);
|
|
456
461
|
|
|
457
|
-
this.action(
|
|
462
|
+
this.action('talk', config.events.question);
|
|
458
463
|
this.talk(config.events.question, this.copy(packet)); // global question event make sure to copy data.
|
|
459
464
|
|
|
460
465
|
if (isAsk) { // isAsk check if the question isAsk and talk
|
|
461
466
|
// if: isAsk wait for the once event which is key'd to the packet ID for specified responses
|
|
467
|
+
this.action('talk', `${key}:ask`);
|
|
462
468
|
this.talk(`${key}:ask`, packet);
|
|
463
469
|
this.once(`${key}:ask:${packet.id}`, answer => {
|
|
464
|
-
this.action('
|
|
470
|
+
this.action('talk', config.events.ask);
|
|
465
471
|
this.talk(config.events.ask, this.copy(answer));
|
|
466
472
|
return this.finish(answer, resolve); // if:isAsk resolve the answer from the call
|
|
467
473
|
});
|
|
468
474
|
}
|
|
469
475
|
else { // else: answer tue question locally
|
|
470
|
-
this.
|
|
476
|
+
this.state('answer', `question:${method}`);
|
|
471
477
|
return this.answer(packet, resolve, reject);
|
|
472
478
|
}
|
|
473
479
|
}
|
|
474
480
|
catch(e) {
|
|
481
|
+
this.state('reject', 'question');
|
|
475
482
|
return this.error(e); // if a overall error happens this witll call this.error
|
|
476
483
|
}
|
|
477
484
|
});
|
|
@@ -489,18 +496,16 @@ class Deva {
|
|
|
489
496
|
***************/
|
|
490
497
|
answer(packet, resolve, reject) {
|
|
491
498
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
492
|
-
this.zone('answer');
|
|
493
499
|
const agent = this.agent();
|
|
494
500
|
const client = this.client();
|
|
495
501
|
// check if method exists and is of type function
|
|
496
502
|
const {method,params} = packet.q.meta;
|
|
497
503
|
const isMethod = this.methods[method] && typeof this.methods[method] == 'function';
|
|
498
|
-
if (!isMethod)
|
|
499
|
-
|
|
500
|
-
}
|
|
504
|
+
if (!isMethod) return resolve(this._methodNotFound(packet)); // resolve method not found if check if check fails
|
|
505
|
+
|
|
501
506
|
// Call the local method to process the question based the extracted parameters
|
|
502
|
-
|
|
503
|
-
|
|
507
|
+
this.zone('answer', method);
|
|
508
|
+
this.methods[method](packet).then(result => {
|
|
504
509
|
// check the result for the text, html, and data object.
|
|
505
510
|
// this is for when answers are returned from nested Devas.
|
|
506
511
|
const text = typeof result === 'object' ? result.text : result;
|
|
@@ -508,6 +513,7 @@ class Deva {
|
|
|
508
513
|
// if the data passed is NOT an object it will FALSE
|
|
509
514
|
const data = typeof result === 'object' ? result.data : false;
|
|
510
515
|
|
|
516
|
+
this.state('set', 'answer')
|
|
511
517
|
const packet_answer = { // setup the packet.a container
|
|
512
518
|
id: this.uid(),
|
|
513
519
|
agent, // set the agent who answered the question
|
|
@@ -523,13 +529,15 @@ class Deva {
|
|
|
523
529
|
created: Date.now(), // set the created date for the answer
|
|
524
530
|
};
|
|
525
531
|
|
|
526
|
-
this.state('answer', method);
|
|
527
532
|
// create a hash for the answer and insert into answer meta.
|
|
528
533
|
packet_answer.meta.hash = this.hash(packet_answer);
|
|
529
534
|
packet.a = packet_answer; // set the packet.a to the packet_answer
|
|
535
|
+
this.action('talk', config.events.answer)
|
|
530
536
|
this.talk(config.events.answer, this.copy(packet)); // global talk event
|
|
537
|
+
this.state('resovle', 'answer')
|
|
531
538
|
return this.finish(packet, resolve); // resolve the packet to the caller.
|
|
532
539
|
}).catch(err => { // catch any errors in the method
|
|
540
|
+
this.state('reject', 'answer');
|
|
533
541
|
return this.error(err, packet, reject); // return this.error with err, packet, reject
|
|
534
542
|
});
|
|
535
543
|
}
|
|
@@ -572,11 +580,10 @@ class Deva {
|
|
|
572
580
|
created: Date.now(),
|
|
573
581
|
};
|
|
574
582
|
|
|
575
|
-
this.action('ask', method);
|
|
576
583
|
try {
|
|
577
584
|
if (typeof this.methods[method] !== 'function') {
|
|
578
585
|
return setImmediate(() => {
|
|
579
|
-
this.
|
|
586
|
+
this.state('invalid', method);
|
|
580
587
|
this.talk(`${this._agent.key}:ask:${packet.id}`, this._methodNotFound(packet));
|
|
581
588
|
});
|
|
582
589
|
}
|
|
@@ -593,7 +600,7 @@ class Deva {
|
|
|
593
600
|
packet_answer.text = result;
|
|
594
601
|
}
|
|
595
602
|
|
|
596
|
-
this.state('
|
|
603
|
+
this.state('set', `ask:${method}`);
|
|
597
604
|
packet_answer.meta.hash = this.hash(packet_answer);
|
|
598
605
|
packet.a = packet_answer;
|
|
599
606
|
this.talk(config.events.answer, this.copy(packet)); // global talk event
|
|
@@ -742,17 +749,15 @@ class Deva {
|
|
|
742
749
|
usage: this.finish(data, resolve)
|
|
743
750
|
***************/
|
|
744
751
|
finish(packet, resolve) {
|
|
745
|
-
this.zone('finish'); // set the zone to finish
|
|
746
752
|
if (!this._active) return Promise.resolve(this._messages.offline);
|
|
753
|
+
this.zone('finish'); // set the finish action
|
|
747
754
|
|
|
748
|
-
this.state('finish'); // set the finish state
|
|
749
755
|
packet.hash = this.hash(packet);// hash the entire packet before finishing.
|
|
750
756
|
// check for agent on finish function in agent
|
|
751
757
|
const hasOnFinish = this.onFinish && typeof this.onFinish === 'function';
|
|
752
758
|
|
|
753
|
-
this.action('finish'); // set the finish action
|
|
754
759
|
// if: agent has on finish then return on finish
|
|
755
|
-
|
|
760
|
+
this.state('finish'); // set the finish state
|
|
756
761
|
if (hasOnFinish) return this.onFinish(packet, resolve);
|
|
757
762
|
// return the provided resolve function or a promise resolve.
|
|
758
763
|
return resolve ? resolve(packet) : Promise.resolve(packet);
|
|
@@ -1016,7 +1021,6 @@ class Deva {
|
|
|
1016
1021
|
describe: return a list of features that are available to the system.
|
|
1017
1022
|
***************/
|
|
1018
1023
|
features() {
|
|
1019
|
-
this.action('func', 'features');
|
|
1020
1024
|
this.state('return', 'features');
|
|
1021
1025
|
return { // return the data object
|
|
1022
1026
|
id: this.uid(true), // set the object id
|
|
@@ -1060,7 +1064,7 @@ class Deva {
|
|
|
1060
1064
|
}
|
|
1061
1065
|
|
|
1062
1066
|
contexts() {
|
|
1063
|
-
this.
|
|
1067
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1064
1068
|
this.state('return', 'contexts');
|
|
1065
1069
|
return {
|
|
1066
1070
|
id: this.uid(true),
|
|
@@ -1104,10 +1108,9 @@ class Deva {
|
|
|
1104
1108
|
usage: this.security()
|
|
1105
1109
|
***************/
|
|
1106
1110
|
security() {
|
|
1111
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1107
1112
|
this.zone('security');
|
|
1108
1113
|
this.feature('security'); // set the security state
|
|
1109
|
-
if (!this._active) return this._messages.offline; // check the active status
|
|
1110
|
-
this.action('feature', 'security'); // set the security state
|
|
1111
1114
|
try {
|
|
1112
1115
|
this.state('return', 'security'); // set the security state
|
|
1113
1116
|
return this.copy(this._security); // return the security feature
|
|
@@ -1121,10 +1124,9 @@ class Deva {
|
|
|
1121
1124
|
usage: this.support()
|
|
1122
1125
|
***************/
|
|
1123
1126
|
support() {
|
|
1127
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1124
1128
|
this.zone('support');
|
|
1125
1129
|
this.feature('support'); // set the support state
|
|
1126
|
-
if (!this._active) return this._messages.offline; // check the active status
|
|
1127
|
-
this.action('feature', 'support'); // set the state to data
|
|
1128
1130
|
try {
|
|
1129
1131
|
this.state('return', 'support'); // set the action to support.
|
|
1130
1132
|
return this.copy(this._support); // return the support feature
|
|
@@ -1140,10 +1142,9 @@ class Deva {
|
|
|
1140
1142
|
usage: this.services()
|
|
1141
1143
|
***************/
|
|
1142
1144
|
services(opts) {
|
|
1145
|
+
if (!this._active) return this._messages.offline; // check the active status
|
|
1143
1146
|
this.zone('services');
|
|
1144
1147
|
this.feature('services'); // set the support state
|
|
1145
|
-
if (!this._active) return this._messages.offline; // check the active status
|
|
1146
|
-
this.action('feature', 'services'); // set the services state
|
|
1147
1148
|
try {
|
|
1148
1149
|
this.state('return', 'services'); // set the services state
|
|
1149
1150
|
return this.copy(this._services); // return the services feature
|
|
@@ -1298,7 +1299,6 @@ class Deva {
|
|
|
1298
1299
|
text,
|
|
1299
1300
|
created: Date.now(),
|
|
1300
1301
|
}
|
|
1301
|
-
this.state('talk', 'prompt')
|
|
1302
1302
|
return this.talk(config.events.prompt, _data);
|
|
1303
1303
|
}
|
|
1304
1304
|
|
|
@@ -1367,8 +1367,8 @@ class Deva {
|
|
|
1367
1367
|
day: { day: 'long' },
|
|
1368
1368
|
log: { year: 'numeric', month: 'short', day: 'numeric' },
|
|
1369
1369
|
};
|
|
1370
|
-
const theDate = d.toLocaleDateString(this._client.locale, formats[format]);
|
|
1371
|
-
const theTime = this.formatTime(d);
|
|
1370
|
+
const theDate = d.toLocaleDateString(this._client.profile.locale, formats[format]);
|
|
1371
|
+
const theTime = time ? this.formatTime(d) : false;
|
|
1372
1372
|
this.state('return', 'formatDate');
|
|
1373
1373
|
return !theTime ? theDate : `${theDate} - ${theTime}`;
|
|
1374
1374
|
}
|
|
@@ -1383,7 +1383,7 @@ class Deva {
|
|
|
1383
1383
|
***************/
|
|
1384
1384
|
formatTime(t) {
|
|
1385
1385
|
this.feature('formatTime');
|
|
1386
|
-
return t.toLocaleTimeString(this._client.locale); // return the formatted time string
|
|
1386
|
+
return t.toLocaleTimeString(this._client.profile.locale); // return the formatted time string
|
|
1387
1387
|
}
|
|
1388
1388
|
|
|
1389
1389
|
/**************
|
|
@@ -1394,13 +1394,27 @@ class Deva {
|
|
|
1394
1394
|
The formatCurrency function will format a currency value based on the setting
|
|
1395
1395
|
in the client profile.
|
|
1396
1396
|
***************/
|
|
1397
|
-
formatCurrency(n) {
|
|
1397
|
+
formatCurrency(n, cur=false) {
|
|
1398
1398
|
this.feature('formatCurrency');
|
|
1399
|
-
|
|
1399
|
+
const currency = cur || this._client.profile.currency;
|
|
1400
|
+
return new Intl.NumberFormat(this._client.profile.locale, { style: 'currency', currency: currency }).format(n);
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
/**************
|
|
1404
|
+
func: formatCurrency
|
|
1405
|
+
params:
|
|
1406
|
+
- n: is the number that you want to return the currency of.
|
|
1407
|
+
describe:
|
|
1408
|
+
The formatCurrency function will format a currency value based on the setting
|
|
1409
|
+
in the client profile.
|
|
1410
|
+
***************/
|
|
1411
|
+
formatNumber(n) {
|
|
1412
|
+
this.feature('formatNumber');
|
|
1413
|
+
return new Intl.NumberFormat(this._client.profile.locale).format(n);
|
|
1400
1414
|
}
|
|
1401
1415
|
|
|
1402
1416
|
/**************
|
|
1403
|
-
func:
|
|
1417
|
+
func: formatPercent
|
|
1404
1418
|
params:
|
|
1405
1419
|
- n: is the number that you want to format as a percent.
|
|
1406
1420
|
- dec: is the number of decimal places to apply to the number.
|
|
@@ -1412,7 +1426,7 @@ class Deva {
|
|
|
1412
1426
|
}
|
|
1413
1427
|
|
|
1414
1428
|
/**************
|
|
1415
|
-
func:
|
|
1429
|
+
func: trimWords
|
|
1416
1430
|
params:
|
|
1417
1431
|
- text: The text to trim.
|
|
1418
1432
|
- maxwords: The number of words to max.
|