@pie-element/math-inline 5.9.9 → 5.9.12

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.
@@ -1,1372 +0,0 @@
1
- import * as mv from '@pie-framework/math-validation';
2
-
3
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
-
5
- /** Used for built-in method references. */
6
-
7
- var objectProto$6 = Object.prototype;
8
-
9
- /**
10
- * Checks if `value` is likely a prototype object.
11
- *
12
- * @private
13
- * @param {*} value The value to check.
14
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
15
- */
16
- function isPrototype$2(value) {
17
- var Ctor = value && value.constructor,
18
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$6;
19
-
20
- return value === proto;
21
- }
22
-
23
- var _isPrototype = isPrototype$2;
24
-
25
- /**
26
- * Creates a unary function that invokes `func` with its argument transformed.
27
- *
28
- * @private
29
- * @param {Function} func The function to wrap.
30
- * @param {Function} transform The argument transform.
31
- * @returns {Function} Returns the new function.
32
- */
33
-
34
- function overArg$1(func, transform) {
35
- return function(arg) {
36
- return func(transform(arg));
37
- };
38
- }
39
-
40
- var _overArg = overArg$1;
41
-
42
- var overArg = _overArg;
43
-
44
- /* Built-in method references for those with the same name as other `lodash` methods. */
45
- var nativeKeys$1 = overArg(Object.keys, Object);
46
-
47
- var _nativeKeys = nativeKeys$1;
48
-
49
- var isPrototype$1 = _isPrototype,
50
- nativeKeys = _nativeKeys;
51
-
52
- /** Used for built-in method references. */
53
- var objectProto$5 = Object.prototype;
54
-
55
- /** Used to check objects for own properties. */
56
- var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
57
-
58
- /**
59
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
60
- *
61
- * @private
62
- * @param {Object} object The object to query.
63
- * @returns {Array} Returns the array of property names.
64
- */
65
- function baseKeys$1(object) {
66
- if (!isPrototype$1(object)) {
67
- return nativeKeys(object);
68
- }
69
- var result = [];
70
- for (var key in Object(object)) {
71
- if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
72
- result.push(key);
73
- }
74
- }
75
- return result;
76
- }
77
-
78
- var _baseKeys = baseKeys$1;
79
-
80
- /** Detect free variable `global` from Node.js. */
81
-
82
- var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
83
-
84
- var _freeGlobal = freeGlobal$1;
85
-
86
- var freeGlobal = _freeGlobal;
87
-
88
- /** Detect free variable `self`. */
89
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
90
-
91
- /** Used as a reference to the global object. */
92
- var root$7 = freeGlobal || freeSelf || Function('return this')();
93
-
94
- var _root = root$7;
95
-
96
- var root$6 = _root;
97
-
98
- /** Built-in value references. */
99
- var Symbol$2 = root$6.Symbol;
100
-
101
- var _Symbol = Symbol$2;
102
-
103
- var Symbol$1 = _Symbol;
104
-
105
- /** Used for built-in method references. */
106
- var objectProto$4 = Object.prototype;
107
-
108
- /** Used to check objects for own properties. */
109
- var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
110
-
111
- /**
112
- * Used to resolve the
113
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
114
- * of values.
115
- */
116
- var nativeObjectToString$1 = objectProto$4.toString;
117
-
118
- /** Built-in value references. */
119
- var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
120
-
121
- /**
122
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
123
- *
124
- * @private
125
- * @param {*} value The value to query.
126
- * @returns {string} Returns the raw `toStringTag`.
127
- */
128
- function getRawTag$1(value) {
129
- var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
130
- tag = value[symToStringTag$1];
131
-
132
- try {
133
- value[symToStringTag$1] = undefined;
134
- var unmasked = true;
135
- } catch (e) {}
136
-
137
- var result = nativeObjectToString$1.call(value);
138
- if (unmasked) {
139
- if (isOwn) {
140
- value[symToStringTag$1] = tag;
141
- } else {
142
- delete value[symToStringTag$1];
143
- }
144
- }
145
- return result;
146
- }
147
-
148
- var _getRawTag = getRawTag$1;
149
-
150
- /** Used for built-in method references. */
151
-
152
- var objectProto$3 = Object.prototype;
153
-
154
- /**
155
- * Used to resolve the
156
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
157
- * of values.
158
- */
159
- var nativeObjectToString = objectProto$3.toString;
160
-
161
- /**
162
- * Converts `value` to a string using `Object.prototype.toString`.
163
- *
164
- * @private
165
- * @param {*} value The value to convert.
166
- * @returns {string} Returns the converted string.
167
- */
168
- function objectToString$1(value) {
169
- return nativeObjectToString.call(value);
170
- }
171
-
172
- var _objectToString = objectToString$1;
173
-
174
- var Symbol = _Symbol,
175
- getRawTag = _getRawTag,
176
- objectToString = _objectToString;
177
-
178
- /** `Object#toString` result references. */
179
- var nullTag = '[object Null]',
180
- undefinedTag = '[object Undefined]';
181
-
182
- /** Built-in value references. */
183
- var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
184
-
185
- /**
186
- * The base implementation of `getTag` without fallbacks for buggy environments.
187
- *
188
- * @private
189
- * @param {*} value The value to query.
190
- * @returns {string} Returns the `toStringTag`.
191
- */
192
- function baseGetTag$4(value) {
193
- if (value == null) {
194
- return value === undefined ? undefinedTag : nullTag;
195
- }
196
- return (symToStringTag && symToStringTag in Object(value))
197
- ? getRawTag(value)
198
- : objectToString(value);
199
- }
200
-
201
- var _baseGetTag = baseGetTag$4;
202
-
203
- /**
204
- * Checks if `value` is the
205
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
206
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
207
- *
208
- * @static
209
- * @memberOf _
210
- * @since 0.1.0
211
- * @category Lang
212
- * @param {*} value The value to check.
213
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
214
- * @example
215
- *
216
- * _.isObject({});
217
- * // => true
218
- *
219
- * _.isObject([1, 2, 3]);
220
- * // => true
221
- *
222
- * _.isObject(_.noop);
223
- * // => true
224
- *
225
- * _.isObject(null);
226
- * // => false
227
- */
228
-
229
- function isObject$2(value) {
230
- var type = typeof value;
231
- return value != null && (type == 'object' || type == 'function');
232
- }
233
-
234
- var isObject_1 = isObject$2;
235
-
236
- var baseGetTag$3 = _baseGetTag,
237
- isObject$1 = isObject_1;
238
-
239
- /** `Object#toString` result references. */
240
- var asyncTag = '[object AsyncFunction]',
241
- funcTag$1 = '[object Function]',
242
- genTag = '[object GeneratorFunction]',
243
- proxyTag = '[object Proxy]';
244
-
245
- /**
246
- * Checks if `value` is classified as a `Function` object.
247
- *
248
- * @static
249
- * @memberOf _
250
- * @since 0.1.0
251
- * @category Lang
252
- * @param {*} value The value to check.
253
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
254
- * @example
255
- *
256
- * _.isFunction(_);
257
- * // => true
258
- *
259
- * _.isFunction(/abc/);
260
- * // => false
261
- */
262
- function isFunction$2(value) {
263
- if (!isObject$1(value)) {
264
- return false;
265
- }
266
- // The use of `Object#toString` avoids issues with the `typeof` operator
267
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
268
- var tag = baseGetTag$3(value);
269
- return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
270
- }
271
-
272
- var isFunction_1 = isFunction$2;
273
-
274
- var root$5 = _root;
275
-
276
- /** Used to detect overreaching core-js shims. */
277
- var coreJsData$1 = root$5['__core-js_shared__'];
278
-
279
- var _coreJsData = coreJsData$1;
280
-
281
- var coreJsData = _coreJsData;
282
-
283
- /** Used to detect methods masquerading as native. */
284
- var maskSrcKey = (function() {
285
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
286
- return uid ? ('Symbol(src)_1.' + uid) : '';
287
- }());
288
-
289
- /**
290
- * Checks if `func` has its source masked.
291
- *
292
- * @private
293
- * @param {Function} func The function to check.
294
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
295
- */
296
- function isMasked$1(func) {
297
- return !!maskSrcKey && (maskSrcKey in func);
298
- }
299
-
300
- var _isMasked = isMasked$1;
301
-
302
- /** Used for built-in method references. */
303
-
304
- var funcProto$1 = Function.prototype;
305
-
306
- /** Used to resolve the decompiled source of functions. */
307
- var funcToString$1 = funcProto$1.toString;
308
-
309
- /**
310
- * Converts `func` to its source code.
311
- *
312
- * @private
313
- * @param {Function} func The function to convert.
314
- * @returns {string} Returns the source code.
315
- */
316
- function toSource$2(func) {
317
- if (func != null) {
318
- try {
319
- return funcToString$1.call(func);
320
- } catch (e) {}
321
- try {
322
- return (func + '');
323
- } catch (e) {}
324
- }
325
- return '';
326
- }
327
-
328
- var _toSource = toSource$2;
329
-
330
- var isFunction$1 = isFunction_1,
331
- isMasked = _isMasked,
332
- isObject = isObject_1,
333
- toSource$1 = _toSource;
334
-
335
- /**
336
- * Used to match `RegExp`
337
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
338
- */
339
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
340
-
341
- /** Used to detect host constructors (Safari). */
342
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
343
-
344
- /** Used for built-in method references. */
345
- var funcProto = Function.prototype,
346
- objectProto$2 = Object.prototype;
347
-
348
- /** Used to resolve the decompiled source of functions. */
349
- var funcToString = funcProto.toString;
350
-
351
- /** Used to check objects for own properties. */
352
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
353
-
354
- /** Used to detect if a method is native. */
355
- var reIsNative = RegExp('^' +
356
- funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
357
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
358
- );
359
-
360
- /**
361
- * The base implementation of `_.isNative` without bad shim checks.
362
- *
363
- * @private
364
- * @param {*} value The value to check.
365
- * @returns {boolean} Returns `true` if `value` is a native function,
366
- * else `false`.
367
- */
368
- function baseIsNative$1(value) {
369
- if (!isObject(value) || isMasked(value)) {
370
- return false;
371
- }
372
- var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
373
- return pattern.test(toSource$1(value));
374
- }
375
-
376
- var _baseIsNative = baseIsNative$1;
377
-
378
- /**
379
- * Gets the value at `key` of `object`.
380
- *
381
- * @private
382
- * @param {Object} [object] The object to query.
383
- * @param {string} key The key of the property to get.
384
- * @returns {*} Returns the property value.
385
- */
386
-
387
- function getValue$1(object, key) {
388
- return object == null ? undefined : object[key];
389
- }
390
-
391
- var _getValue = getValue$1;
392
-
393
- var baseIsNative = _baseIsNative,
394
- getValue = _getValue;
395
-
396
- /**
397
- * Gets the native function at `key` of `object`.
398
- *
399
- * @private
400
- * @param {Object} object The object to query.
401
- * @param {string} key The key of the method to get.
402
- * @returns {*} Returns the function if it's native, else `undefined`.
403
- */
404
- function getNative$5(object, key) {
405
- var value = getValue(object, key);
406
- return baseIsNative(value) ? value : undefined;
407
- }
408
-
409
- var _getNative = getNative$5;
410
-
411
- var getNative$4 = _getNative,
412
- root$4 = _root;
413
-
414
- /* Built-in method references that are verified to be native. */
415
- var DataView$1 = getNative$4(root$4, 'DataView');
416
-
417
- var _DataView = DataView$1;
418
-
419
- var getNative$3 = _getNative,
420
- root$3 = _root;
421
-
422
- /* Built-in method references that are verified to be native. */
423
- var Map$1 = getNative$3(root$3, 'Map');
424
-
425
- var _Map = Map$1;
426
-
427
- var getNative$2 = _getNative,
428
- root$2 = _root;
429
-
430
- /* Built-in method references that are verified to be native. */
431
- var Promise$2 = getNative$2(root$2, 'Promise');
432
-
433
- var _Promise = Promise$2;
434
-
435
- var getNative$1 = _getNative,
436
- root$1 = _root;
437
-
438
- /* Built-in method references that are verified to be native. */
439
- var Set$1 = getNative$1(root$1, 'Set');
440
-
441
- var _Set = Set$1;
442
-
443
- var getNative = _getNative,
444
- root = _root;
445
-
446
- /* Built-in method references that are verified to be native. */
447
- var WeakMap$1 = getNative(root, 'WeakMap');
448
-
449
- var _WeakMap = WeakMap$1;
450
-
451
- var DataView = _DataView,
452
- Map = _Map,
453
- Promise$1 = _Promise,
454
- Set = _Set,
455
- WeakMap = _WeakMap,
456
- baseGetTag$2 = _baseGetTag,
457
- toSource = _toSource;
458
-
459
- /** `Object#toString` result references. */
460
- var mapTag$2 = '[object Map]',
461
- objectTag$1 = '[object Object]',
462
- promiseTag = '[object Promise]',
463
- setTag$2 = '[object Set]',
464
- weakMapTag$1 = '[object WeakMap]';
465
-
466
- var dataViewTag$1 = '[object DataView]';
467
-
468
- /** Used to detect maps, sets, and weakmaps. */
469
- var dataViewCtorString = toSource(DataView),
470
- mapCtorString = toSource(Map),
471
- promiseCtorString = toSource(Promise$1),
472
- setCtorString = toSource(Set),
473
- weakMapCtorString = toSource(WeakMap);
474
-
475
- /**
476
- * Gets the `toStringTag` of `value`.
477
- *
478
- * @private
479
- * @param {*} value The value to query.
480
- * @returns {string} Returns the `toStringTag`.
481
- */
482
- var getTag$1 = baseGetTag$2;
483
-
484
- // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
485
- if ((DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
486
- (Map && getTag$1(new Map) != mapTag$2) ||
487
- (Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag) ||
488
- (Set && getTag$1(new Set) != setTag$2) ||
489
- (WeakMap && getTag$1(new WeakMap) != weakMapTag$1)) {
490
- getTag$1 = function(value) {
491
- var result = baseGetTag$2(value),
492
- Ctor = result == objectTag$1 ? value.constructor : undefined,
493
- ctorString = Ctor ? toSource(Ctor) : '';
494
-
495
- if (ctorString) {
496
- switch (ctorString) {
497
- case dataViewCtorString: return dataViewTag$1;
498
- case mapCtorString: return mapTag$2;
499
- case promiseCtorString: return promiseTag;
500
- case setCtorString: return setTag$2;
501
- case weakMapCtorString: return weakMapTag$1;
502
- }
503
- }
504
- return result;
505
- };
506
- }
507
-
508
- var _getTag = getTag$1;
509
-
510
- /**
511
- * Checks if `value` is object-like. A value is object-like if it's not `null`
512
- * and has a `typeof` result of "object".
513
- *
514
- * @static
515
- * @memberOf _
516
- * @since 4.0.0
517
- * @category Lang
518
- * @param {*} value The value to check.
519
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
520
- * @example
521
- *
522
- * _.isObjectLike({});
523
- * // => true
524
- *
525
- * _.isObjectLike([1, 2, 3]);
526
- * // => true
527
- *
528
- * _.isObjectLike(_.noop);
529
- * // => false
530
- *
531
- * _.isObjectLike(null);
532
- * // => false
533
- */
534
-
535
- function isObjectLike$3(value) {
536
- return value != null && typeof value == 'object';
537
- }
538
-
539
- var isObjectLike_1 = isObjectLike$3;
540
-
541
- var baseGetTag$1 = _baseGetTag,
542
- isObjectLike$2 = isObjectLike_1;
543
-
544
- /** `Object#toString` result references. */
545
- var argsTag$1 = '[object Arguments]';
546
-
547
- /**
548
- * The base implementation of `_.isArguments`.
549
- *
550
- * @private
551
- * @param {*} value The value to check.
552
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
553
- */
554
- function baseIsArguments$1(value) {
555
- return isObjectLike$2(value) && baseGetTag$1(value) == argsTag$1;
556
- }
557
-
558
- var _baseIsArguments = baseIsArguments$1;
559
-
560
- var baseIsArguments = _baseIsArguments,
561
- isObjectLike$1 = isObjectLike_1;
562
-
563
- /** Used for built-in method references. */
564
- var objectProto$1 = Object.prototype;
565
-
566
- /** Used to check objects for own properties. */
567
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
568
-
569
- /** Built-in value references. */
570
- var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
571
-
572
- /**
573
- * Checks if `value` is likely an `arguments` object.
574
- *
575
- * @static
576
- * @memberOf _
577
- * @since 0.1.0
578
- * @category Lang
579
- * @param {*} value The value to check.
580
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
581
- * else `false`.
582
- * @example
583
- *
584
- * _.isArguments(function() { return arguments; }());
585
- * // => true
586
- *
587
- * _.isArguments([1, 2, 3]);
588
- * // => false
589
- */
590
- var isArguments$1 = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
591
- return isObjectLike$1(value) && hasOwnProperty$1.call(value, 'callee') &&
592
- !propertyIsEnumerable.call(value, 'callee');
593
- };
594
-
595
- var isArguments_1 = isArguments$1;
596
-
597
- /**
598
- * Checks if `value` is classified as an `Array` object.
599
- *
600
- * @static
601
- * @memberOf _
602
- * @since 0.1.0
603
- * @category Lang
604
- * @param {*} value The value to check.
605
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
606
- * @example
607
- *
608
- * _.isArray([1, 2, 3]);
609
- * // => true
610
- *
611
- * _.isArray(document.body.children);
612
- * // => false
613
- *
614
- * _.isArray('abc');
615
- * // => false
616
- *
617
- * _.isArray(_.noop);
618
- * // => false
619
- */
620
-
621
- var isArray$1 = Array.isArray;
622
-
623
- var isArray_1 = isArray$1;
624
-
625
- /** Used as references for various `Number` constants. */
626
-
627
- var MAX_SAFE_INTEGER = 9007199254740991;
628
-
629
- /**
630
- * Checks if `value` is a valid array-like length.
631
- *
632
- * **Note:** This method is loosely based on
633
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
634
- *
635
- * @static
636
- * @memberOf _
637
- * @since 4.0.0
638
- * @category Lang
639
- * @param {*} value The value to check.
640
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
641
- * @example
642
- *
643
- * _.isLength(3);
644
- * // => true
645
- *
646
- * _.isLength(Number.MIN_VALUE);
647
- * // => false
648
- *
649
- * _.isLength(Infinity);
650
- * // => false
651
- *
652
- * _.isLength('3');
653
- * // => false
654
- */
655
- function isLength$2(value) {
656
- return typeof value == 'number' &&
657
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
658
- }
659
-
660
- var isLength_1 = isLength$2;
661
-
662
- var isFunction = isFunction_1,
663
- isLength$1 = isLength_1;
664
-
665
- /**
666
- * Checks if `value` is array-like. A value is considered array-like if it's
667
- * not a function and has a `value.length` that's an integer greater than or
668
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
669
- *
670
- * @static
671
- * @memberOf _
672
- * @since 4.0.0
673
- * @category Lang
674
- * @param {*} value The value to check.
675
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
676
- * @example
677
- *
678
- * _.isArrayLike([1, 2, 3]);
679
- * // => true
680
- *
681
- * _.isArrayLike(document.body.children);
682
- * // => true
683
- *
684
- * _.isArrayLike('abc');
685
- * // => true
686
- *
687
- * _.isArrayLike(_.noop);
688
- * // => false
689
- */
690
- function isArrayLike$1(value) {
691
- return value != null && isLength$1(value.length) && !isFunction(value);
692
- }
693
-
694
- var isArrayLike_1 = isArrayLike$1;
695
-
696
- var isBuffer$1 = {exports: {}};
697
-
698
- /**
699
- * This method returns `false`.
700
- *
701
- * @static
702
- * @memberOf _
703
- * @since 4.13.0
704
- * @category Util
705
- * @returns {boolean} Returns `false`.
706
- * @example
707
- *
708
- * _.times(2, _.stubFalse);
709
- * // => [false, false]
710
- */
711
-
712
- function stubFalse() {
713
- return false;
714
- }
715
-
716
- var stubFalse_1 = stubFalse;
717
-
718
- (function (module, exports) {
719
- var root = _root,
720
- stubFalse = stubFalse_1;
721
-
722
- /** Detect free variable `exports`. */
723
- var freeExports = exports && !exports.nodeType && exports;
724
-
725
- /** Detect free variable `module`. */
726
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
727
-
728
- /** Detect the popular CommonJS extension `module.exports`. */
729
- var moduleExports = freeModule && freeModule.exports === freeExports;
730
-
731
- /** Built-in value references. */
732
- var Buffer = moduleExports ? root.Buffer : undefined;
733
-
734
- /* Built-in method references for those with the same name as other `lodash` methods. */
735
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
736
-
737
- /**
738
- * Checks if `value` is a buffer.
739
- *
740
- * @static
741
- * @memberOf _
742
- * @since 4.3.0
743
- * @category Lang
744
- * @param {*} value The value to check.
745
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
746
- * @example
747
- *
748
- * _.isBuffer(new Buffer(2));
749
- * // => true
750
- *
751
- * _.isBuffer(new Uint8Array(2));
752
- * // => false
753
- */
754
- var isBuffer = nativeIsBuffer || stubFalse;
755
-
756
- module.exports = isBuffer;
757
- }(isBuffer$1, isBuffer$1.exports));
758
-
759
- var baseGetTag = _baseGetTag,
760
- isLength = isLength_1,
761
- isObjectLike = isObjectLike_1;
762
-
763
- /** `Object#toString` result references. */
764
- var argsTag = '[object Arguments]',
765
- arrayTag = '[object Array]',
766
- boolTag = '[object Boolean]',
767
- dateTag = '[object Date]',
768
- errorTag = '[object Error]',
769
- funcTag = '[object Function]',
770
- mapTag$1 = '[object Map]',
771
- numberTag = '[object Number]',
772
- objectTag = '[object Object]',
773
- regexpTag = '[object RegExp]',
774
- setTag$1 = '[object Set]',
775
- stringTag = '[object String]',
776
- weakMapTag = '[object WeakMap]';
777
-
778
- var arrayBufferTag = '[object ArrayBuffer]',
779
- dataViewTag = '[object DataView]',
780
- float32Tag = '[object Float32Array]',
781
- float64Tag = '[object Float64Array]',
782
- int8Tag = '[object Int8Array]',
783
- int16Tag = '[object Int16Array]',
784
- int32Tag = '[object Int32Array]',
785
- uint8Tag = '[object Uint8Array]',
786
- uint8ClampedTag = '[object Uint8ClampedArray]',
787
- uint16Tag = '[object Uint16Array]',
788
- uint32Tag = '[object Uint32Array]';
789
-
790
- /** Used to identify `toStringTag` values of typed arrays. */
791
- var typedArrayTags = {};
792
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
793
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
794
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
795
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
796
- typedArrayTags[uint32Tag] = true;
797
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
798
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
799
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
800
- typedArrayTags[errorTag] = typedArrayTags[funcTag] =
801
- typedArrayTags[mapTag$1] = typedArrayTags[numberTag] =
802
- typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
803
- typedArrayTags[setTag$1] = typedArrayTags[stringTag] =
804
- typedArrayTags[weakMapTag] = false;
805
-
806
- /**
807
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
808
- *
809
- * @private
810
- * @param {*} value The value to check.
811
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
812
- */
813
- function baseIsTypedArray$1(value) {
814
- return isObjectLike(value) &&
815
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
816
- }
817
-
818
- var _baseIsTypedArray = baseIsTypedArray$1;
819
-
820
- /**
821
- * The base implementation of `_.unary` without support for storing metadata.
822
- *
823
- * @private
824
- * @param {Function} func The function to cap arguments for.
825
- * @returns {Function} Returns the new capped function.
826
- */
827
-
828
- function baseUnary$1(func) {
829
- return function(value) {
830
- return func(value);
831
- };
832
- }
833
-
834
- var _baseUnary = baseUnary$1;
835
-
836
- var _nodeUtil = {exports: {}};
837
-
838
- (function (module, exports) {
839
- var freeGlobal = _freeGlobal;
840
-
841
- /** Detect free variable `exports`. */
842
- var freeExports = exports && !exports.nodeType && exports;
843
-
844
- /** Detect free variable `module`. */
845
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
846
-
847
- /** Detect the popular CommonJS extension `module.exports`. */
848
- var moduleExports = freeModule && freeModule.exports === freeExports;
849
-
850
- /** Detect free variable `process` from Node.js. */
851
- var freeProcess = moduleExports && freeGlobal.process;
852
-
853
- /** Used to access faster Node.js helpers. */
854
- var nodeUtil = (function() {
855
- try {
856
- // Use `util.types` for Node.js 10+.
857
- var types = freeModule && freeModule.require && freeModule.require('util').types;
858
-
859
- if (types) {
860
- return types;
861
- }
862
-
863
- // Legacy `process.binding('util')` for Node.js < 10.
864
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
865
- } catch (e) {}
866
- }());
867
-
868
- module.exports = nodeUtil;
869
- }(_nodeUtil, _nodeUtil.exports));
870
-
871
- var baseIsTypedArray = _baseIsTypedArray,
872
- baseUnary = _baseUnary,
873
- nodeUtil = _nodeUtil.exports;
874
-
875
- /* Node.js helper references. */
876
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
877
-
878
- /**
879
- * Checks if `value` is classified as a typed array.
880
- *
881
- * @static
882
- * @memberOf _
883
- * @since 3.0.0
884
- * @category Lang
885
- * @param {*} value The value to check.
886
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
887
- * @example
888
- *
889
- * _.isTypedArray(new Uint8Array);
890
- * // => true
891
- *
892
- * _.isTypedArray([]);
893
- * // => false
894
- */
895
- var isTypedArray$1 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
896
-
897
- var isTypedArray_1 = isTypedArray$1;
898
-
899
- var baseKeys = _baseKeys,
900
- getTag = _getTag,
901
- isArguments = isArguments_1,
902
- isArray = isArray_1,
903
- isArrayLike = isArrayLike_1,
904
- isBuffer = isBuffer$1.exports,
905
- isPrototype = _isPrototype,
906
- isTypedArray = isTypedArray_1;
907
-
908
- /** `Object#toString` result references. */
909
- var mapTag = '[object Map]',
910
- setTag = '[object Set]';
911
-
912
- /** Used for built-in method references. */
913
- var objectProto = Object.prototype;
914
-
915
- /** Used to check objects for own properties. */
916
- var hasOwnProperty = objectProto.hasOwnProperty;
917
-
918
- /**
919
- * Checks if `value` is an empty object, collection, map, or set.
920
- *
921
- * Objects are considered empty if they have no own enumerable string keyed
922
- * properties.
923
- *
924
- * Array-like values such as `arguments` objects, arrays, buffers, strings, or
925
- * jQuery-like collections are considered empty if they have a `length` of `0`.
926
- * Similarly, maps and sets are considered empty if they have a `size` of `0`.
927
- *
928
- * @static
929
- * @memberOf _
930
- * @since 0.1.0
931
- * @category Lang
932
- * @param {*} value The value to check.
933
- * @returns {boolean} Returns `true` if `value` is empty, else `false`.
934
- * @example
935
- *
936
- * _.isEmpty(null);
937
- * // => true
938
- *
939
- * _.isEmpty(true);
940
- * // => true
941
- *
942
- * _.isEmpty(1);
943
- * // => true
944
- *
945
- * _.isEmpty([1, 2, 3]);
946
- * // => false
947
- *
948
- * _.isEmpty({ 'a': 1 });
949
- * // => false
950
- */
951
- function isEmpty(value) {
952
- if (value == null) {
953
- return true;
954
- }
955
- if (isArrayLike(value) &&
956
- (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
957
- isBuffer(value) || isTypedArray(value) || isArguments(value))) {
958
- return !value.length;
959
- }
960
- var tag = getTag(value);
961
- if (tag == mapTag || tag == setTag) {
962
- return !value.size;
963
- }
964
- if (isPrototype(value)) {
965
- return !baseKeys(value).length;
966
- }
967
- for (var key in value) {
968
- if (hasOwnProperty.call(value, key)) {
969
- return false;
970
- }
971
- }
972
- return true;
973
- }
974
-
975
- var isEmpty_1 = isEmpty;
976
-
977
- const defaults$1 = {
978
- correct: { type: 'default', default: 'Correct', custom: 'Correct' },
979
- incorrect: { type: 'default', default: 'Incorrect', custom: 'Incorrect' },
980
- partial: { type: 'default', default: 'Nearly', custom: 'Nearly' },
981
- unanswered: {
982
- type: 'default',
983
- default: 'You have not entered a response',
984
- custom: 'You have not entered a response'
985
- }
986
- };
987
-
988
- /**
989
- * @typedef {Object} FeedbackConfig
990
- * @property {'default'|'none'|'custom'} type
991
- * @property {string} default
992
- * @property {string} custom
993
- *
994
- * @typedef {Object} Feedback
995
- * @property {FeedbackConfig} correct
996
- * @property {FeedbackConfig} incorrect
997
- * @property {FeedbackConfig} partial
998
- */
999
-
1000
- const normalizeCorrectness = c => {
1001
- if (c === 'partially-correct') {
1002
- return 'partial';
1003
- }
1004
- return c;
1005
- };
1006
-
1007
- /**
1008
- * Get the feedback for the correctness
1009
- *
1010
- * @param {'correct'|'incorrect'|'partial'} correctness
1011
- * @param {Feedback} feedback
1012
- */
1013
- const getFeedbackForCorrectness = (correctness, feedback) =>
1014
- new Promise(resolve => {
1015
- feedback = { ...defaults$1, ...feedback };
1016
- correctness = normalizeCorrectness(correctness);
1017
- const fb = feedback[correctness] || defaults$1[correctness] || {};
1018
- const d = defaults$1[correctness] || {};
1019
- getFeedback(fb, d[fb.type || 'default']).then(result => resolve(result));
1020
- });
1021
-
1022
- /**
1023
- * Get the feedback from a {FeedbackConfig}
1024
- *
1025
- * @param {FeedbackConfig} feedback
1026
- * @param {string} fallback
1027
- */
1028
- const getFeedback = (feedback, fallback) =>
1029
- new Promise(resolve => {
1030
- if (!feedback || feedback.type === 'none') {
1031
- resolve(undefined);
1032
- return;
1033
- }
1034
- feedback = feedback || {};
1035
- const out = feedback[feedback.type] || fallback;
1036
- resolve(out);
1037
- });
1038
-
1039
- const ResponseTypes = {
1040
- advanced: 'Advanced Multi',
1041
- simple: 'Simple'
1042
- };
1043
-
1044
- var defaults = {
1045
- responseType: ResponseTypes.advanced,
1046
- element: 'math-inline',
1047
- feedback: {
1048
- correct: {
1049
- default: 'Correct',
1050
- type: 'none'
1051
- },
1052
- incorrect: {
1053
- default: 'Incorrect',
1054
- type: 'none'
1055
- },
1056
- partial: {
1057
- default: 'Nearly',
1058
- type: 'none'
1059
- }
1060
- },
1061
- note: 'The answer shown above is the primary correct answer specified by the author for this item, but other answers may also be recognized as correct.',
1062
- equationEditor: '8',
1063
- expression: '',
1064
- question: '',
1065
- responses: [],
1066
- customKeys: []
1067
- };
1068
-
1069
- const getResponseCorrectness = (model, answerItem, isOutcome) => {
1070
- const correctResponses = model.responses;
1071
- const isAdvanced = model.responseType === ResponseTypes.advanced;
1072
-
1073
- if (!answerItem) {
1074
- return {
1075
- correctness: 'unanswered',
1076
- score: isOutcome ? 0 : '0%',
1077
- correct: false,
1078
- };
1079
- }
1080
-
1081
- const isAnswerCorrect = getIsAnswerCorrect(
1082
- isAdvanced ? correctResponses : correctResponses.slice(0, 1),
1083
- answerItem
1084
- );
1085
-
1086
- const correctnessObject = {
1087
- correctness: 'incorrect',
1088
- score: isOutcome ? 0 : '0%',
1089
- correct: false,
1090
- };
1091
-
1092
- if (isAnswerCorrect) {
1093
- correctnessObject.correctness = 'correct';
1094
- correctnessObject.score = isOutcome ? 1 : '100%';
1095
- correctnessObject.correct = true;
1096
- }
1097
-
1098
- return correctnessObject;
1099
- };
1100
-
1101
-
1102
- function getIsAnswerCorrect(correctResponseItem, answerItem) {
1103
- let answerCorrect = false;
1104
-
1105
- (correctResponseItem || []).forEach(correctResponse => {
1106
-
1107
- let opts = {
1108
- mode: correctResponse.validation || defaults.validationDefault
1109
- };
1110
-
1111
- if (opts.mode == 'literal') {
1112
- opts.literal = {
1113
- allowTrailingZeros: correctResponse.allowTrailingZeros || false,
1114
- ignoreOrder: correctResponse.ignoreOrder || false,
1115
- };
1116
- }
1117
-
1118
- if (!answerCorrect) {
1119
- const acceptedValues = [correctResponse.answer].concat(
1120
- Object.keys(correctResponse.alternates || {}).map(
1121
- alternateId => correctResponse.alternates[alternateId]
1122
- )
1123
- ) || [];
1124
-
1125
- try {
1126
- for (let i = 0; i < acceptedValues.length; i++) {
1127
- answerCorrect = mv.latexEqual(answerItem, acceptedValues[i], opts);
1128
-
1129
- if (answerCorrect) {
1130
- break;
1131
- }
1132
- }
1133
- } catch (e) {
1134
-
1135
- answerCorrect = false;
1136
- }
1137
- }
1138
- });
1139
-
1140
- return answerCorrect;
1141
- }
1142
-
1143
- const getCorrectness = (question, env, session, isOutcome) => {
1144
- if (env.mode === 'evaluate') {
1145
- return getResponseCorrectness(
1146
- question,
1147
- question.responseType === ResponseTypes.advanced
1148
- ? (session && session.completeAnswer) || ''
1149
- : session && session.response,
1150
- isOutcome
1151
- );
1152
- }
1153
- };
1154
-
1155
- function createDefaultModel(model = {}) {
1156
- return new Promise((resolve) => {
1157
- resolve({
1158
- config: {
1159
- ...defaults,
1160
- ...model,
1161
- },
1162
- });
1163
- });
1164
- }
1165
-
1166
- const outcome = (question, session, env) => {
1167
- return new Promise((resolve) => {
1168
- if (env.mode !== 'evaluate') {
1169
- resolve({ score: undefined, completed: undefined });
1170
- } else {
1171
- if (!session || isEmpty_1(session)) {
1172
- resolve({ score: 0, empty: true });
1173
- } else {
1174
- const correctness = getCorrectness(question, env, session, true);
1175
-
1176
- resolve({ score: correctness.score });
1177
- }
1178
- }
1179
- });
1180
- };
1181
-
1182
- const normalize = (question) => {
1183
-
1184
- // making sure that defaults are set
1185
- if (!isEmpty_1(question.responses)) {
1186
- question.responses = question.responses.map(correctResponse => ({
1187
- ...correctResponse, validation: correctResponse.validation || question.validationDefault,
1188
- allowTrailingZeros: correctResponse.allowTrailingZeros || question.allowTrailingZerosDefault,
1189
- ignoreOrder: correctResponse.ignoreOrder || question.ignoreOrderDefault
1190
- }));
1191
- }
1192
-
1193
- return {
1194
- ...defaults,
1195
- feedbackEnabled: true,
1196
- promptEnabled: true,
1197
- rationaleEnabled: true,
1198
- teacherInstructionsEnabled: true,
1199
- studentInstructionsEnabled: true,
1200
- ...question,
1201
- }
1202
- };
1203
-
1204
- function model(question, session, env) {
1205
- return new Promise((resolve) => {
1206
- const normalizedQuestion = normalize(question);
1207
- const correctness = getCorrectness(normalizedQuestion, env, session);
1208
- const { responses, ...config } = normalizedQuestion;
1209
-
1210
- if (config.responseType === ResponseTypes.simple) {
1211
- config.responses = responses.slice(0, 1);
1212
- } else {
1213
- config.responses = responses;
1214
- config.customKeys = [];
1215
- }
1216
-
1217
- const fb =
1218
- env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled
1219
- ? getFeedbackForCorrectness(correctness, normalizedQuestion.feedback)
1220
- : Promise.resolve(undefined);
1221
-
1222
- fb.then((feedback) => {
1223
- const base = {
1224
- config,
1225
- correctness,
1226
- feedback,
1227
- disabled: env.mode !== 'gather',
1228
- view: env.mode === 'view',
1229
- };
1230
-
1231
- const out = base;
1232
- let showNote = false;
1233
-
1234
- ((config && config.responses) || []).forEach((response) => {
1235
- if (
1236
- response.validation === 'symbolic' ||
1237
- Object.keys(response.alternates || {}).length > 0
1238
- ) {
1239
- showNote = true;
1240
- return;
1241
- }
1242
- });
1243
-
1244
- if (env.mode === 'evaluate') {
1245
- out.correctResponse = {};
1246
- out.config.showNote = showNote;
1247
- } else {
1248
- out.config.responses = [];
1249
- out.config.showNote = false;
1250
- }
1251
-
1252
- if (
1253
- env.role === 'instructor' &&
1254
- (env.mode === 'view' || env.mode === 'evaluate')
1255
- ) {
1256
- out.rationale = normalizedQuestion.rationaleEnabled
1257
- ? normalizedQuestion.rationale
1258
- : null;
1259
- out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled
1260
- ? normalizedQuestion.teacherInstructions
1261
- : null;
1262
- } else {
1263
- out.rationale = null;
1264
- out.teacherInstructions = null;
1265
- out.config.rationale = null;
1266
- out.config.teacherInstructions = null;
1267
- }
1268
-
1269
- out.config.env = env;
1270
- out.config.prompt = normalizedQuestion.promptEnabled
1271
- ? normalizedQuestion.prompt
1272
- : null;
1273
- resolve(out);
1274
- });
1275
- });
1276
- }
1277
-
1278
- const escape = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
1279
-
1280
- const simpleSessionResponse = (question) =>
1281
- new Promise((resolve) => {
1282
- const { responses, id } = question;
1283
- const { answer } = responses && responses.length ? responses[0] : {};
1284
-
1285
- resolve({
1286
- id,
1287
- response: answer || '',
1288
- completeAnswer: answer || ''
1289
- });
1290
- });
1291
-
1292
- const advancedSessionResponse = (question) =>
1293
- new Promise((resolve, reject) => {
1294
- const { responses, id } = question;
1295
- const { answer } = responses && responses.length ? responses[0] : {};
1296
-
1297
- if (!answer) {
1298
- resolve({
1299
- id,
1300
- answers: {},
1301
- completeAnswer: ''
1302
- });
1303
-
1304
- return;
1305
- }
1306
-
1307
- try {
1308
- const e = question.expression;
1309
- const RESPONSE_TOKEN = /\\{\\{\s*response\s*\\}\\}/g;
1310
-
1311
- const o = escape(e).split(RESPONSE_TOKEN);
1312
- const to = o.map((t) => (t === '' ? t : t.replace(/\s+/g, () => '\\s*')));
1313
- const tt = to.join('(.*)');
1314
-
1315
- const m = answer.match(new RegExp(tt));
1316
-
1317
- const count = o.length - 1;
1318
-
1319
- if (!m) {
1320
- resolve({
1321
- id,
1322
- answers: {},
1323
- completeAnswer: answer
1324
- });
1325
-
1326
- console.log(`can not find match: ${o} in ${answer}`);
1327
-
1328
- return;
1329
- }
1330
-
1331
- m.shift();
1332
-
1333
- const answers = {};
1334
-
1335
- for (var i = 0; i < count; i++) {
1336
- answers[`r${i + 1}`] = { value: m[i].trim() };
1337
- }
1338
-
1339
- resolve({
1340
- id,
1341
- answers,
1342
- completeAnswer: answer
1343
- });
1344
- } catch (e) {
1345
- resolve({
1346
- id,
1347
- answers: {},
1348
- completeAnswer: answer
1349
- });
1350
-
1351
- console.error(e.toString());
1352
- }
1353
- });
1354
-
1355
- const createCorrectResponseSession = (question, env) => {
1356
- if (env.mode === 'evaluate' || env.role !== 'instructor') {
1357
- // eslint-disable-next-line no-console
1358
- console.error(
1359
- 'can not create correct response session if mode is evaluate or role is not instructor'
1360
- );
1361
-
1362
- return Promise.resolve(null);
1363
- }
1364
-
1365
- if ((question.responseType || '').toLowerCase() === 'simple') {
1366
- return simpleSessionResponse(question);
1367
- } else {
1368
- return advancedSessionResponse(question);
1369
- }
1370
- };
1371
-
1372
- export { createCorrectResponseSession, createDefaultModel, model, normalize, outcome };