compareText.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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'];
  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. var matrixAlgorithmSuite = (0, _matrixAlgorithmSuite.createMatrixAlgorithmSuite)({
  16. typed: typed,
  17. matrix: matrix
  18. });
  19. /**
  20. * Compare two strings lexically. Comparison is case sensitive.
  21. * Returns 1 when x > y, -1 when x < y, and 0 when x == y.
  22. *
  23. * For matrices, the function is evaluated element wise.
  24. *
  25. * Syntax:
  26. *
  27. * math.compareText(x, y)
  28. *
  29. * Examples:
  30. *
  31. * math.compareText('B', 'A') // returns 1
  32. * math.compareText('2', '10') // returns 1
  33. * math.compare('2', '10') // returns -1
  34. * math.compareNatural('2', '10') // returns -1
  35. *
  36. * math.compareText('B', ['A', 'B', 'C']) // returns [1, 0, -1]
  37. *
  38. * See also:
  39. *
  40. * equal, equalText, compare, compareNatural
  41. *
  42. * @param {string | Array | DenseMatrix} x First string to compare
  43. * @param {string | Array | DenseMatrix} y Second string to compare
  44. * @return {number | Array | DenseMatrix} Returns the result of the comparison:
  45. * 1 when x > y, -1 when x < y, and 0 when x == y.
  46. */
  47. return typed(name, _string.compareText, matrixAlgorithmSuite({
  48. elop: _string.compareText,
  49. Ds: true
  50. }));
  51. });
  52. exports.createCompareText = createCompareText;
  53. var createCompareTextNumber = /* #__PURE__ */(0, _factory.factory)(name, ['typed'], function (_ref2) {
  54. var typed = _ref2.typed;
  55. return typed(name, _string.compareText);
  56. });
  57. exports.createCompareTextNumber = createCompareTextNumber;