25
25
* @module
26
26
*/
27
27
import type { Context , Denops , Dispatcher , Meta } from "@denops/core" ;
28
- import { is } from "@core/unknownutil" ;
28
+ import { isArray } from "@core/unknownutil/is/array" ;
29
+ import { isBoolean } from "@core/unknownutil/is/boolean" ;
30
+ import { isFunction } from "@core/unknownutil/is/function" ;
31
+ import { isInstanceOf } from "@core/unknownutil/is/instance-of" ;
32
+ import { isLiteralOf } from "@core/unknownutil/is/literal-of" ;
33
+ import { isNullish } from "@core/unknownutil/is/nullish" ;
34
+ import { isNumber } from "@core/unknownutil/is/number" ;
35
+ import { isObjectOf } from "@core/unknownutil/is/object-of" ;
36
+ import { isRecord } from "@core/unknownutil/is/record" ;
37
+ import { isString } from "@core/unknownutil/is/string" ;
38
+ import { isSymbol } from "@core/unknownutil/is/symbol" ;
39
+ import { isUndefined } from "@core/unknownutil/is/undefined" ;
29
40
import { ulid } from "@std/ulid" ;
30
41
import { execute } from "./execute.ts" ;
31
42
@@ -55,7 +66,7 @@ type TemplateSubstitutions = any[];
55
66
const cacheKey = "denops_std/helper/expr_string@1" ;
56
67
57
68
async function ensurePrerequisites ( denops : Denops ) : Promise < string > {
58
- if ( is . String ( denops . context [ cacheKey ] ) ) {
69
+ if ( isString ( denops . context [ cacheKey ] ) ) {
59
70
return denops . context [ cacheKey ] ;
60
71
}
61
72
const suffix = ulid ( ) ;
@@ -95,9 +106,9 @@ export function exprQuote(
95
106
} ) ;
96
107
}
97
108
98
- const isInstanceOfBoolean = is . InstanceOf ( Boolean ) ;
99
- const isInstanceOfNumber = is . InstanceOf ( Number ) ;
100
- const isInstanceOfString = is . InstanceOf ( String ) ;
109
+ const isInstanceOfBoolean = isInstanceOf ( Boolean ) ;
110
+ const isInstanceOfNumber = isInstanceOf ( Number ) ;
111
+ const isInstanceOfString = isInstanceOf ( String ) ;
101
112
102
113
/**
103
114
* Returns `true` if the value is a string marked as Vim's string constant format.
@@ -110,17 +121,17 @@ const isInstanceOfString = is.InstanceOf(String);
110
121
* ```
111
122
*/
112
123
export function isExprString ( x : unknown ) : x is ExprString {
113
- return is . ObjectOf ( {
114
- [ EXPR_STRING_MARK ] : is . LiteralOf ( 1 ) ,
124
+ return isObjectOf ( {
125
+ [ EXPR_STRING_MARK ] : isLiteralOf ( 1 ) ,
115
126
} ) ( x ) ;
116
127
}
117
128
118
129
function isJsonable ( x : unknown ) : x is Jsonable {
119
- return x != null && is . Function ( ( x as Jsonable ) . toJSON ) ;
130
+ return x != null && isFunction ( ( x as Jsonable ) . toJSON ) ;
120
131
}
121
132
122
133
function isIgnoreRecordValue ( x : unknown ) : boolean {
123
- return is . Undefined ( x ) || is . Function ( x ) || is . Symbol ( x ) ;
134
+ return isUndefined ( x ) || isFunction ( x ) || isSymbol ( x ) ;
124
135
}
125
136
126
137
/**
@@ -134,26 +145,26 @@ export function vimStringify(value: unknown, key?: string | number): string {
134
145
// Return Vim's expr-string
135
146
return `"${ value . replaceAll ( '"' , '\\"' ) } "` ;
136
147
}
137
- if ( ( is . Nullish ( value ) || is . Function ( value ) || is . Symbol ( value ) ) ) {
148
+ if ( ( isNullish ( value ) || isFunction ( value ) || isSymbol ( value ) ) ) {
138
149
return "v:null" ;
139
150
}
140
- if ( is . Boolean ( value ) || isInstanceOfBoolean ( value ) ) {
151
+ if ( isBoolean ( value ) || isInstanceOfBoolean ( value ) ) {
141
152
// Return v:true or v:false
142
153
return `v:${ value } ` ;
143
154
}
144
- if ( is . Number ( value ) || isInstanceOfNumber ( value ) ) {
155
+ if ( isNumber ( value ) || isInstanceOfNumber ( value ) ) {
145
156
// Replace `5e-10` to `5.0e-10`
146
157
return `${ value } ` . replace ( / ^ ( \d + ) e / , "$1.0e" ) ;
147
158
}
148
- if ( is . String ( value ) || isInstanceOfString ( value ) ) {
159
+ if ( isString ( value ) || isInstanceOfString ( value ) ) {
149
160
// Returns Vim's literal-string
150
161
return `'${ value . replaceAll ( "'" , "''" ) } '` ;
151
162
}
152
- if ( is . Array ( value ) ) {
163
+ if ( isArray ( value ) ) {
153
164
// Returns Vim's list
154
165
return `[${ value . map ( vimStringify ) . join ( "," ) } ]` ;
155
166
}
156
- if ( is . Record ( value ) ) {
167
+ if ( isRecord ( value ) ) {
157
168
// Returns Vim's dict
158
169
return `{${
159
170
Object . entries ( value )
@@ -169,7 +180,7 @@ export function vimStringify(value: unknown, key?: string | number): string {
169
180
}
170
181
171
182
function trimEndOfArgs ( args : unknown [ ] ) : unknown [ ] {
172
- const last = args . findIndex ( is . Undefined ) ;
183
+ const last = args . findIndex ( isUndefined ) ;
173
184
return last < 0 ? args : args . slice ( 0 , last ) ;
174
185
}
175
186
0 commit comments