1+ import { sumBy } from 'lodash'
2+
13export const truncateString = ( str : string , maxLength : number ) => {
24 if ( str . length <= maxLength ) {
35 return str
@@ -15,7 +17,8 @@ export const replaceNonStandardPlaceholderComments = (
1517 placeholder : '// ... existing code ...' ,
1618 } ,
1719 {
18- regex : / \/ \* \s * \. { 3 } \s * .* (?: r e s t | u n c h a n g e d | k e e p | f i l e ) .* (?: \s * \. { 3 } ) ? \s * \* \/ / gi,
20+ regex :
21+ / \/ \* \s * \. { 3 } \s * .* (?: r e s t | u n c h a n g e d | k e e p | f i l e ) .* (?: \s * \. { 3 } ) ? \s * \* \/ / gi,
1922 placeholder : '/* ... existing code ... */' ,
2023 } ,
2124 // Python, Ruby, R comments
@@ -25,7 +28,8 @@ export const replaceNonStandardPlaceholderComments = (
2528 } ,
2629 // HTML-style comments
2730 {
28- regex : / < ! - - \s * \. { 3 } \s * .* (?: r e s t | u n c h a n g e d | k e e p | f i l e ) .* (?: \s * \. { 3 } ) ? \s * - - > / gi,
31+ regex :
32+ / < ! - - \s * \. { 3 } \s * .* (?: r e s t | u n c h a n g e d | k e e p | f i l e ) .* (?: \s * \. { 3 } ) ? \s * - - > / gi,
2933 placeholder : '<!-- ... existing code ... -->' ,
3034 } ,
3135 // SQL, Haskell, Lua comments
@@ -48,3 +52,7 @@ export const replaceNonStandardPlaceholderComments = (
4852
4953 return updatedContent
5054}
55+
56+ export const randBoolFromStr = ( str : string ) => {
57+ return sumBy ( str . split ( '' ) , ( char ) => char . charCodeAt ( 0 ) ) % 2 === 0
58+ }
0 commit comments