source: imaps-frontend/node_modules/update-browserslist-db/utils.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 712 bytes
Line 
1const { EOL } = require('os')
2
3const getFirstRegexpMatchOrDefault = (text, regexp, defaultValue) => {
4 regexp.lastIndex = 0 // https://stackoverflow.com/a/11477448/4536543
5 let match = regexp.exec(text)
6 if (match !== null) {
7 return match[1]
8 } else {
9 return defaultValue
10 }
11}
12
13const DEFAULT_INDENT = ' '
14const INDENT_REGEXP = /^([ \t]+)[^\s]/m
15
16module.exports.detectIndent = text =>
17 getFirstRegexpMatchOrDefault(text, INDENT_REGEXP, DEFAULT_INDENT)
18module.exports.DEFAULT_INDENT = DEFAULT_INDENT
19
20const DEFAULT_EOL = EOL
21const EOL_REGEXP = /(\r\n|\n|\r)/g
22
23module.exports.detectEOL = text =>
24 getFirstRegexpMatchOrDefault(text, EOL_REGEXP, DEFAULT_EOL)
25module.exports.DEFAULT_EOL = DEFAULT_EOL
Note: See TracBrowser for help on using the repository browser.