@yookue/ts-lang-utils
    Preparing search index...

    Function compare

    • Returns 1 if source greater than target, -1 if source less than target, 0 if equals

      Parameters

      • Optionalsource: null | string | number

        the first comparable

      • Optionaltarget: null | string | number

        the second comparable

      • nullGreater: boolean = false

        whether a nil (undefined or null) value is considered greater than another non-nil value

      Returns number

      1 if source greater than target, -1 if source less than target, 0 if equals

      David Hsing

      compare(undefined, null);    // 0
      compare(3, undefined, true); // -1
      compare(3, undefined, false); // 1
      compare(3, 2); // 1
      compare(2, 3); // -1