Polyfills.cs 668 B

123456789101112131415161718192021
  1. using System.Runtime.CompilerServices;
  2. namespace Jint;
  3. internal static class Polyfills
  4. {
  5. #if NETFRAMEWORK || NETSTANDARD2_0
  6. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  7. internal static bool Contains(this string source, char c) => source.IndexOf(c) != -1;
  8. #endif
  9. #if NETFRAMEWORK
  10. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  11. internal static bool Contains(this ReadOnlySpan<string> source, string c) => source.IndexOf(c) != -1;
  12. #endif
  13. #if NETFRAMEWORK || NETSTANDARD2_0
  14. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  15. internal static bool StartsWith(this string source, char c) => source.Length > 0 && source[0] == c;
  16. #endif
  17. }