UNPKG
@ashejuniper/skim
Version:
latest (0.1.0)
0.1.0
Skim over text in JavaScript strings
@ashejuniper/skim
/
src
/
skim.js
20 lines
(17 loc)
•
340 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function
skim
(
corpus, textToSkim
) {
try
{
if
( !corpus.
startsWith
(textToSkim) ) {
return
new
Error
(
`corpus does not begin with "
${textToSkim}
"`
); }
return
corpus.
substr
(textToSkim.
length
); }
catch
(error) {
return
error; } }
module
.
exports
= skim;