MCPcopy
hub / github.com/braziljs/eloquente-javascript / startAndEnd

Function startAndEnd

src/transform.mjs:18–24  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

16}
17
18function startAndEnd(text) {
19 var words = text.split(/\W+/);
20 if (!words[0]) words.shift();
21 if (!words[words.length - 1]) words.pop();
22 if (words.length <= 6) return words.join(" ");
23 return words.slice(0, 3).concat(words.slice(words.length - 3)).join(" ");
24}
25
26function tokenText(token) {
27 if (token.type == "text" || token.type == "code_inline") return token.content

Callers 1

transformTokensFunction · 0.85

Calls 5

shiftMethod · 0.80
popMethod · 0.80
splitMethod · 0.45
joinMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected