版博士V2.0程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

string.d.ts 5.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /**
  2. * @since 2.10.0
  3. */
  4. import * as E from './Eq'
  5. import * as M from './Monoid'
  6. import * as S from './Semigroup'
  7. import * as O from './Ord'
  8. import * as Sh from './Show'
  9. import { Refinement } from './Refinement'
  10. import { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray'
  11. /**
  12. * @example
  13. * import * as S from 'fp-ts/string'
  14. *
  15. * assert.deepStrictEqual(S.Eq.equals('a', 'a'), true)
  16. * assert.deepStrictEqual(S.Eq.equals('a', 'b'), false)
  17. *
  18. * @category instances
  19. * @since 2.10.0
  20. */
  21. export declare const Eq: E.Eq<string>
  22. /**
  23. * `string` semigroup under concatenation.
  24. *
  25. * @example
  26. * import * as S from 'fp-ts/string'
  27. *
  28. * assert.deepStrictEqual(S.Semigroup.concat('a', 'b'), 'ab')
  29. *
  30. * @category instances
  31. * @since 2.10.0
  32. */
  33. export declare const Semigroup: S.Semigroup<string>
  34. /**
  35. * An empty `string`.
  36. *
  37. * @since 2.10.0
  38. */
  39. export declare const empty = ''
  40. /**
  41. * `string` monoid under concatenation.
  42. *
  43. * The `empty` value is `''`.
  44. *
  45. * @example
  46. * import * as S from 'fp-ts/string'
  47. *
  48. * assert.deepStrictEqual(S.Monoid.concat('a', 'b'), 'ab')
  49. * assert.deepStrictEqual(S.Monoid.concat('a', S.Monoid.empty), 'a')
  50. *
  51. * @category instances
  52. * @since 2.10.0
  53. */
  54. export declare const Monoid: M.Monoid<string>
  55. /**
  56. * @example
  57. * import * as S from 'fp-ts/string'
  58. *
  59. * assert.deepStrictEqual(S.Ord.compare('a', 'a'), 0)
  60. * assert.deepStrictEqual(S.Ord.compare('a', 'b'), -1)
  61. * assert.deepStrictEqual(S.Ord.compare('b', 'a'), 1)
  62. *
  63. * @category instances
  64. * @since 2.10.0
  65. */
  66. export declare const Ord: O.Ord<string>
  67. /**
  68. * @example
  69. * import * as S from 'fp-ts/string'
  70. *
  71. * assert.deepStrictEqual(S.Show.show('a'), '"a"')
  72. *
  73. * @category instances
  74. * @since 2.10.0
  75. */
  76. export declare const Show: Sh.Show<string>
  77. /**
  78. * @example
  79. * import * as S from 'fp-ts/string'
  80. *
  81. * assert.deepStrictEqual(S.isString('a'), true)
  82. * assert.deepStrictEqual(S.isString(1), false)
  83. *
  84. * @category refinements
  85. * @since 2.11.0
  86. */
  87. export declare const isString: Refinement<unknown, string>
  88. /**
  89. * @example
  90. * import * as S from 'fp-ts/string'
  91. * import { pipe } from 'fp-ts/function'
  92. *
  93. * assert.deepStrictEqual(pipe('a', S.toUpperCase), 'A')
  94. *
  95. * @since 2.11.0
  96. */
  97. export declare const toUpperCase: (s: string) => string
  98. /**
  99. * @example
  100. * import * as S from 'fp-ts/string'
  101. * import { pipe } from 'fp-ts/function'
  102. *
  103. * assert.deepStrictEqual(pipe('A', S.toLowerCase), 'a')
  104. *
  105. * @since 2.11.0
  106. */
  107. export declare const toLowerCase: (s: string) => string
  108. /**
  109. * @example
  110. * import * as S from 'fp-ts/string'
  111. * import { pipe } from 'fp-ts/function'
  112. *
  113. * assert.deepStrictEqual(pipe('abc', S.replace('b', 'd')), 'adc')
  114. *
  115. * @since 2.11.0
  116. */
  117. export declare const replace: (searchValue: string | RegExp, replaceValue: string) => (s: string) => string
  118. /**
  119. * @example
  120. * import * as S from 'fp-ts/string'
  121. * import { pipe } from 'fp-ts/function'
  122. *
  123. * assert.deepStrictEqual(pipe(' a ', S.trim), 'a')
  124. *
  125. * @since 2.11.0
  126. */
  127. export declare const trim: (s: string) => string
  128. /**
  129. * @example
  130. * import * as S from 'fp-ts/string'
  131. * import { pipe } from 'fp-ts/function'
  132. *
  133. * assert.deepStrictEqual(pipe(' a ', S.trimLeft), 'a ')
  134. *
  135. * @since 2.11.0
  136. */
  137. export declare const trimLeft: (s: string) => string
  138. /**
  139. * @example
  140. * import * as S from 'fp-ts/string'
  141. * import { pipe } from 'fp-ts/function'
  142. *
  143. * assert.deepStrictEqual(pipe(' a ', S.trimRight), ' a')
  144. *
  145. * @since 2.11.0
  146. */
  147. export declare const trimRight: (s: string) => string
  148. /**
  149. * @example
  150. * import * as S from 'fp-ts/string'
  151. * import { pipe } from 'fp-ts/function'
  152. *
  153. * assert.deepStrictEqual(pipe('abcd', S.slice(1, 3)), 'bc')
  154. *
  155. * @since 2.11.0
  156. */
  157. export declare const slice: (start: number, end: number) => (s: string) => string
  158. /**
  159. * Test whether a `string` is empty.
  160. *
  161. * @example
  162. * import * as S from 'fp-ts/string'
  163. * import { pipe } from 'fp-ts/function'
  164. *
  165. * assert.deepStrictEqual(pipe('', S.isEmpty), true)
  166. * assert.deepStrictEqual(pipe('a', S.isEmpty), false)
  167. *
  168. * @since 2.10.0
  169. */
  170. export declare const isEmpty: (s: string) => boolean
  171. /**
  172. * Calculate the number of characters in a `string`.
  173. *
  174. * @example
  175. * import * as S from 'fp-ts/string'
  176. * import { pipe } from 'fp-ts/function'
  177. *
  178. * assert.deepStrictEqual(pipe('abc', S.size), 3)
  179. *
  180. * @since 2.10.0
  181. */
  182. export declare const size: (s: string) => number
  183. /**
  184. * @example
  185. * import * as S from 'fp-ts/string'
  186. * import { pipe } from 'fp-ts/function'
  187. *
  188. * assert.deepStrictEqual(pipe('abc', S.split('')), ['a', 'b', 'c'])
  189. * assert.deepStrictEqual(pipe('', S.split('')), [''])
  190. *
  191. * @since 2.11.0
  192. */
  193. export declare const split: (separator: string | RegExp) => (s: string) => ReadonlyNonEmptyArray<string>
  194. /**
  195. * @example
  196. * import * as S from 'fp-ts/string'
  197. * import { pipe } from 'fp-ts/function'
  198. *
  199. * assert.deepStrictEqual(pipe('abc', S.includes('b')), true)
  200. * assert.deepStrictEqual(pipe('abc', S.includes('d')), false)
  201. *
  202. * @since 2.11.0
  203. */
  204. export declare const includes: (searchString: string, position?: number) => (s: string) => boolean
  205. /**
  206. * @example
  207. * import * as S from 'fp-ts/string'
  208. * import { pipe } from 'fp-ts/function'
  209. *
  210. * assert.deepStrictEqual(pipe('abc', S.startsWith('a')), true)
  211. * assert.deepStrictEqual(pipe('bc', S.startsWith('a')), false)
  212. *
  213. * @since 2.11.0
  214. */
  215. export declare const startsWith: (searchString: string, position?: number) => (s: string) => boolean
  216. /**
  217. * @example
  218. * import * as S from 'fp-ts/string'
  219. * import { pipe } from 'fp-ts/function'
  220. *
  221. * assert.deepStrictEqual(pipe('abc', S.endsWith('c')), true)
  222. * assert.deepStrictEqual(pipe('ab', S.endsWith('c')), false)
  223. *
  224. * @since 2.11.0
  225. */
  226. export declare const endsWith: (searchString: string, position?: number) => (s: string) => boolean