compareText.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createCompareTextNumber = exports.createCompareText = void 0;
  6. var _string = require("../../utils/string.js");
  7. var _factory = require("../../utils/factory.js");
  8. var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
  9. var name = 'compareText';
  10. var dependencies = ['typed', 'matrix', 'concat'];
  11. _string.compareText.signature = 'any, any';
  12. var createCompareText = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
  13. var typed = _ref.typed,
  14. matrix = _ref.matrix,
  15. concat = _ref.concat;
  16. var matrixAlgorithmSuite = (0, _matrixAlgorithmSuite.createMatrixAlgorithmSuite)({
  17. typed: typed,
  18. matrix: matrix,
  19. concat: concat
  20. });
  21. /**
  22. * Compare two strings lexically. Comparison is case sensitive.
  23. * Returns 1 when x > y, -1 when x < y, and 0 when x == y.
  24. *
  25. * For matrices, the function is evaluated element wise.
  26. *
  27. * Syntax:
  28. *
  29. * math.compareText(x, y)
  30. *
  31. * Examples:
  32. *
  33. * math.compareText('B', 'A') // returns 1
  34. * math.compareText('2', '10') // returns 1
  35. * math.compare('2', '10') // returns -1
  36. * math.compareNatural('2', '10') // returns -1
  37. *
  38. * math.compareText('B', ['A', 'B', 'C']) // returns [1, 0, -1]
  39. *
  40. * See also:
  41. *
  42. * equal, equalText, compare, compareNatural
  43. *
  44. * @param {string | Array | DenseMatrix} x First string to compare
  45. * @param {string | Array | DenseMatrix} y Second string to compare
  46. * @return {number | Array | DenseMatrix} Returns the result of the comparison:
  47. * 1 when x > y, -1 when x < y, and 0 when x == y.
  48. */
  49. return typed(name, _string.compareText, matrixAlgorithmSuite({
  50. elop: _string.compareText,
  51. Ds: true
  52. }));
  53. });
  54. exports.createCompareText = createCompareText;
  55. var createCompareTextNumber = /* #__PURE__ */(0, _factory.factory)(name, ['typed'], function (_ref2) {
  56. var typed = _ref2.typed;
  57. return typed(name, _string.compareText);
  58. });
  59. exports.createCompareTextNumber = createCompareTextNumber;