File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,7 +80,6 @@ In browsers with [`esm.sh`][esmsh]:
8080## Types
8181
8282This package is fully typed with [ TypeScript] [ ] .
83- It exports no additional types.
8483
8584## Project
8685
Original file line number Diff line number Diff line change 22
33exports [` e2e:mark-util-character > should expose public api 1` ] = `
44[
5+ "eol",
56 "eos",
67 "htab",
78 "is",
Original file line number Diff line number Diff line change 22
33exports [` e2e:mark-util-character > should expose public api 1` ] = `
44[
5+ "eol",
56 "eos",
67 "htab",
78 "is",
Original file line number Diff line number Diff line change 22
33exports [` e2e:mark-util-character > should expose public api 1` ] = `
44[
5+ "eol",
56 "eos",
67 "htab",
78 "is",
Original file line number Diff line number Diff line change 1+ /**
2+ * @file Unit Tests - eol
3+ * @module mark-util-character/tests/unit/eol
4+ */
5+
6+ import { codes } from '@flex-development/mark-util-symbol'
7+ import testSubject from '../eol.mts'
8+
9+ describe ( 'unit:eol' , ( ) => {
10+ it ( 'should return `false` if `code` is not line ending code' , ( ) => {
11+ expect ( testSubject ( codes . space ) ) . to . be . false
12+ } )
13+
14+ it . each < [ keyof typeof codes ] > ( [
15+ [ 'cr' ] ,
16+ [ 'crlf' ] ,
17+ [ 'lf' ] ,
18+ [ 'ls' ] ,
19+ [ 'ps' ] ,
20+ [ 'vcr' ] ,
21+ [ 'vlf' ]
22+ ] ) ( 'should return `true` if `code` is line ending code (`codes.%s`)' , key => {
23+ expect ( testSubject ( codes [ key ] ) ) . to . be . true
24+ } )
25+ } )
Original file line number Diff line number Diff line change 1+ /**
2+ * @file eol
3+ * @module mark-util-character/eol
4+ */
5+
6+ import type { LineEnding } from '@flex-development/mark-util-character'
7+ import { codes } from '@flex-development/mark-util-symbol'
8+
9+ /**
10+ * Check if `code` represents a line ending.
11+ *
12+ * @see {@linkcode LineEnding }
13+ *
14+ * @this {void}
15+ *
16+ * @param {unknown } code
17+ * The character code to check
18+ * @return {code is LineEnding }
19+ * `true` if `code` is line ending code, `false` otherwise
20+ */
21+ function eol ( this : void , code : unknown ) : code is LineEnding {
22+ switch ( code ) {
23+ case codes . cr :
24+ case codes . crlf :
25+ case codes . lf :
26+ case codes . ls :
27+ case codes . ps :
28+ case codes . vcr :
29+ case codes . vlf :
30+ return true
31+ default :
32+ return false
33+ }
34+ }
35+
36+ export default eol
Original file line number Diff line number Diff line change 33 * @module mark-util-character
44 */
55
6+ export { default as eol } from './eol.mts'
67export { default as eos } from './eos.mts'
78export { default as htab } from './htab.mts'
89export { default as is , default as isCode } from './is.mts'
10+ export type * from './types/index.mts'
911export { default as vtab } from './vtab.mts'
Original file line number Diff line number Diff line change 1+ /**
2+ * @file Type Tests - LineEnding
3+ * @module mark-util-character/types/tests/unit-d/LineEnding
4+ */
5+
6+ import type { codes } from '@flex-development/mark-util-symbol'
7+ import type TestSubject from '../line-ending.mts'
8+
9+ describe ( 'unit-d:types/LineEnding' , ( ) => {
10+ it ( 'should extract typeof codes.cr' , ( ) => {
11+ expectTypeOf < TestSubject > ( ) . extract < typeof codes . cr > ( ) . not . toBeNever ( )
12+ } )
13+
14+ it ( 'should extract typeof codes.crlf' , ( ) => {
15+ expectTypeOf < TestSubject > ( ) . extract < typeof codes . crlf > ( ) . not . toBeNever ( )
16+ } )
17+
18+ it ( 'should extract typeof codes.lf' , ( ) => {
19+ expectTypeOf < TestSubject > ( ) . extract < typeof codes . lf > ( ) . not . toBeNever ( )
20+ } )
21+
22+ it ( 'should extract typeof codes.ls' , ( ) => {
23+ expectTypeOf < TestSubject > ( ) . extract < typeof codes . ls > ( ) . not . toBeNever ( )
24+ } )
25+
26+ it ( 'should extract typeof codes.ps' , ( ) => {
27+ expectTypeOf < TestSubject > ( ) . extract < typeof codes . ps > ( ) . not . toBeNever ( )
28+ } )
29+
30+ it ( 'should extract typeof codes.vcr' , ( ) => {
31+ expectTypeOf < TestSubject > ( ) . extract < typeof codes . vcr > ( ) . not . toBeNever ( )
32+ } )
33+
34+ it ( 'should extract typeof codes.vlf' , ( ) => {
35+ expectTypeOf < TestSubject > ( ) . extract < typeof codes . vlf > ( ) . not . toBeNever ( )
36+ } )
37+ } )
Original file line number Diff line number Diff line change 1+ /**
2+ * @file Entry Point - Type Aliases
3+ * @module mark-util-character/types
4+ */
5+
6+ export type { default as LineEnding } from './line-ending.mts'
Original file line number Diff line number Diff line change 1+ /**
2+ * @file Type Aliases - LineEnding
3+ * @module mark-util-character/types/LineEnding
4+ */
5+
6+ import type { codes } from '@flex-development/mark-util-symbol'
7+
8+ /**
9+ * Union of codes representing a line ending.
10+ *
11+ * @see {@linkcode codes.cr }
12+ * @see {@linkcode codes.crlf }
13+ * @see {@linkcode codes.lf }
14+ * @see {@linkcode codes.ls }
15+ * @see {@linkcode codes.ps }
16+ * @see {@linkcode codes.vcr }
17+ * @see {@linkcode codes.vlf }
18+ */
19+ type LineEnding =
20+ | typeof codes . cr
21+ | typeof codes . crlf
22+ | typeof codes . lf
23+ | typeof codes . ls
24+ | typeof codes . ps
25+ | typeof codes . vcr
26+ | typeof codes . vlf
27+
28+ export type { LineEnding as default }
You can’t perform that action at this time.
0 commit comments