Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/antfu/utils
/ ensurePrefix
Function
ensurePrefix
src/string.ts:17–21 ·
view source on GitHub ↗
(prefix: string, str: string)
Source
from the content-addressed store, hash-verified
15
* @category String
16
*/
17
export
function
ensurePrefix(prefix: string, str: string) {
18
if
(!str.startsWith(prefix))
19
return
prefix + str
20
return
str
21
}
22
23
/**
24
* Ensure suffix of a string
Callers
1
string.test.ts
File · 0.90
Calls
no outgoing calls
Tested by
no test coverage detected