Skip to content

Commit db304f9

Browse files
removed gulp, updated dependencies
1 parent c8bcb95 commit db304f9

File tree

13 files changed

+3487
-6689
lines changed

13 files changed

+3487
-6689
lines changed

dist/index.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ class IniSection {
207207
}
208208
}
209209

210+
const systemLineBreak = process && process.platform === 'win32' ? '\r\n' : '\n';
211+
210212
class Ini {
211213
static merge(...inis) {
212214
let mergeLines = (section, newSection) => {
@@ -241,7 +243,7 @@ class Ini {
241243
constructor(text = '', lineBreak) {
242244
if (typeof text !== 'string')
243245
throw new Error('Input must be a string.');
244-
this.lineBreak = lineBreak || this.determineLineBreak(text)
246+
this.lineBreak = lineBreak || this.determineLineBreak(text);
245247
this.sections = [];
246248
let currentSection = this.globals = new IniSection();
247249
if (text.length === 0) return;
@@ -256,23 +258,9 @@ class Ini {
256258
}
257259

258260
determineLineBreak(text) {
259-
if(text === '') {
260-
return typeof process !== 'undefined' &&
261-
process.platform === 'win32' ? '\r\n' : '\n'
262-
} else {
263-
let lineBreak
264-
if(['\r\n', '\n'].some((t) => {
265-
if (text.split(t).length > 1) {
266-
lineBreak = t
267-
return true
268-
}
269-
})) {
270-
return lineBreak
271-
} else {
272-
return typeof process !== 'undefined' &&
273-
process.platform === 'win32' ? '\r\n' : '\n'
274-
}
275-
}
261+
return ['\r\n', '\n'].find(lineBreak => {
262+
return text.includes(lineBreak);
263+
}) || systemLineBreak;
276264
}
277265

278266
getSection(name) {

gulpfile.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

index.js

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,8 @@
1-
const sectionExpr = /^\[(.*)\]/,
2-
commentExpr = /[;#](?: )?(.+)/,
3-
lineExpr = /(^\s*[;#])|(^\[[^\]]*\])|(^.+$)/,
4-
quotedExpr = /^(\s*['"]).+$/,
5-
lineTypes = {
6-
blank: 0,
7-
comment: 1,
8-
header: 2,
9-
pair: 3
10-
},
11-
reservedWords = {
12-
"true": true,
13-
"false": false,
14-
"null": null
15-
},
16-
isBlankLine = line => line.lineType === lineTypes.blank,
17-
isCommentLine = line => line.lineType === lineTypes.comment,
18-
isSectionLine = line => sectionExpr.test(line);
19-
20-
// CLASSES
21-
//= require src/iniLine.js
22-
//= require src/iniSection.js
23-
//= require src/ini.js
1+
const {lineTypes} = require('./src/helpers');
242

253
module.exports = {
26-
Ini: Ini,
27-
IniSection: IniSection,
28-
IniLine: IniLine,
4+
Ini: require('./src/ini'),
5+
IniSection: require('./src/iniSection'),
6+
IniLine: require('./src/iniLine'),
297
lineTypes: lineTypes
30-
};
8+
};

0 commit comments

Comments
 (0)