jass-vue 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +43 -0
  4. data/lib/jass/vue.rb +12 -0
  5. data/lib/jass/vue/version.rb +5 -0
  6. data/vendor/node_modules/arr-diff/index.js +58 -0
  7. data/vendor/node_modules/arr-diff/package.json +49 -0
  8. data/vendor/node_modules/arr-flatten/index.js +22 -0
  9. data/vendor/node_modules/arr-flatten/package.json +76 -0
  10. data/vendor/node_modules/array-unique/index.js +28 -0
  11. data/vendor/node_modules/array-unique/package.json +37 -0
  12. data/vendor/node_modules/braces/index.js +399 -0
  13. data/vendor/node_modules/braces/package.json +83 -0
  14. data/vendor/node_modules/de-indent/index.js +45 -0
  15. data/vendor/node_modules/de-indent/package.json +25 -0
  16. data/vendor/node_modules/de-indent/test.js +30 -0
  17. data/vendor/node_modules/estree-walker/dist/estree-walker.es.js +55 -0
  18. data/vendor/node_modules/estree-walker/dist/estree-walker.es6.js +59 -0
  19. data/vendor/node_modules/estree-walker/dist/estree-walker.umd.js +65 -0
  20. data/vendor/node_modules/estree-walker/package.json +33 -0
  21. data/vendor/node_modules/estree-walker/src/estree-walker.js +49 -0
  22. data/vendor/node_modules/expand-brackets/index.js +163 -0
  23. data/vendor/node_modules/expand-brackets/package.json +62 -0
  24. data/vendor/node_modules/expand-range/index.js +43 -0
  25. data/vendor/node_modules/expand-range/package.json +73 -0
  26. data/vendor/node_modules/extglob/index.js +178 -0
  27. data/vendor/node_modules/extglob/package.json +60 -0
  28. data/vendor/node_modules/filename-regex/index.js +10 -0
  29. data/vendor/node_modules/filename-regex/package.json +50 -0
  30. data/vendor/node_modules/fill-range/index.js +408 -0
  31. data/vendor/node_modules/fill-range/package.json +61 -0
  32. data/vendor/node_modules/for-in/index.js +16 -0
  33. data/vendor/node_modules/for-in/package.json +68 -0
  34. data/vendor/node_modules/for-own/index.js +19 -0
  35. data/vendor/node_modules/for-own/package.json +70 -0
  36. data/vendor/node_modules/glob-base/index.js +51 -0
  37. data/vendor/node_modules/glob-base/package.json +52 -0
  38. data/vendor/node_modules/glob-parent/index.js +10 -0
  39. data/vendor/node_modules/glob-parent/package.json +35 -0
  40. data/vendor/node_modules/glob-parent/test.js +28 -0
  41. data/vendor/node_modules/he/bin/he +148 -0
  42. data/vendor/node_modules/he/he.js +342 -0
  43. data/vendor/node_modules/he/man/he.1 +78 -0
  44. data/vendor/node_modules/he/package.json +56 -0
  45. data/vendor/node_modules/is-buffer/index.js +21 -0
  46. data/vendor/node_modules/is-buffer/package.json +51 -0
  47. data/vendor/node_modules/is-dotfile/index.js +14 -0
  48. data/vendor/node_modules/is-dotfile/package.json +69 -0
  49. data/vendor/node_modules/is-equal-shallow/index.js +27 -0
  50. data/vendor/node_modules/is-equal-shallow/package.json +54 -0
  51. data/vendor/node_modules/is-extendable/index.js +13 -0
  52. data/vendor/node_modules/is-extendable/package.json +51 -0
  53. data/vendor/node_modules/is-extglob/index.js +11 -0
  54. data/vendor/node_modules/is-extglob/package.json +48 -0
  55. data/vendor/node_modules/is-glob/index.js +14 -0
  56. data/vendor/node_modules/is-glob/package.json +60 -0
  57. data/vendor/node_modules/is-number/index.js +19 -0
  58. data/vendor/node_modules/is-number/package.json +59 -0
  59. data/vendor/node_modules/is-posix-bracket/index.js +10 -0
  60. data/vendor/node_modules/is-posix-bracket/package.json +64 -0
  61. data/vendor/node_modules/is-primitive/index.js +13 -0
  62. data/vendor/node_modules/is-primitive/package.json +46 -0
  63. data/vendor/node_modules/isarray/index.js +5 -0
  64. data/vendor/node_modules/isarray/package.json +45 -0
  65. data/vendor/node_modules/isarray/test.js +20 -0
  66. data/vendor/node_modules/isobject/index.js +14 -0
  67. data/vendor/node_modules/isobject/package.json +67 -0
  68. data/vendor/node_modules/kind-of/index.js +116 -0
  69. data/vendor/node_modules/kind-of/package.json +90 -0
  70. data/vendor/node_modules/magic-string/dist/magic-string.cjs.js +1287 -0
  71. data/vendor/node_modules/magic-string/dist/magic-string.es.js +1283 -0
  72. data/vendor/node_modules/magic-string/dist/magic-string.umd.js +1339 -0
  73. data/vendor/node_modules/magic-string/package.json +60 -0
  74. data/vendor/node_modules/magic-string/src/Bundle.js +263 -0
  75. data/vendor/node_modules/magic-string/src/Chunk.js +154 -0
  76. data/vendor/node_modules/magic-string/src/MagicString.js +618 -0
  77. data/vendor/node_modules/magic-string/src/index-legacy.js +6 -0
  78. data/vendor/node_modules/magic-string/src/index.js +4 -0
  79. data/vendor/node_modules/magic-string/src/utils/Mappings.js +117 -0
  80. data/vendor/node_modules/magic-string/src/utils/SourceMap.js +21 -0
  81. data/vendor/node_modules/magic-string/src/utils/Stats.js +18 -0
  82. data/vendor/node_modules/magic-string/src/utils/btoa.js +13 -0
  83. data/vendor/node_modules/magic-string/src/utils/getLocator.js +35 -0
  84. data/vendor/node_modules/magic-string/src/utils/getRelativePath.js +18 -0
  85. data/vendor/node_modules/magic-string/src/utils/guessIndent.js +25 -0
  86. data/vendor/node_modules/magic-string/src/utils/hasOwnProp.js +1 -0
  87. data/vendor/node_modules/magic-string/src/utils/isObject.js +5 -0
  88. data/vendor/node_modules/micromatch/index.js +431 -0
  89. data/vendor/node_modules/micromatch/lib/chars.js +67 -0
  90. data/vendor/node_modules/micromatch/lib/expand.js +304 -0
  91. data/vendor/node_modules/micromatch/lib/glob.js +193 -0
  92. data/vendor/node_modules/micromatch/lib/utils.js +149 -0
  93. data/vendor/node_modules/micromatch/package.json +114 -0
  94. data/vendor/node_modules/normalize-path/index.js +19 -0
  95. data/vendor/node_modules/normalize-path/package.json +78 -0
  96. data/vendor/node_modules/object.omit/index.js +40 -0
  97. data/vendor/node_modules/object.omit/package.json +67 -0
  98. data/vendor/node_modules/parse-glob/index.js +156 -0
  99. data/vendor/node_modules/parse-glob/package.json +62 -0
  100. data/vendor/node_modules/preserve/index.js +54 -0
  101. data/vendor/node_modules/preserve/package.json +48 -0
  102. data/vendor/node_modules/preserve/test.js +48 -0
  103. data/vendor/node_modules/randomatic/index.js +82 -0
  104. data/vendor/node_modules/randomatic/node_modules/is-number/index.js +22 -0
  105. data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/index.js +116 -0
  106. data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/package.json +90 -0
  107. data/vendor/node_modules/randomatic/node_modules/is-number/package.json +83 -0
  108. data/vendor/node_modules/randomatic/node_modules/kind-of/index.js +119 -0
  109. data/vendor/node_modules/randomatic/node_modules/kind-of/package.json +90 -0
  110. data/vendor/node_modules/randomatic/package.json +78 -0
  111. data/vendor/node_modules/regex-cache/index.js +68 -0
  112. data/vendor/node_modules/regex-cache/package.json +64 -0
  113. data/vendor/node_modules/remove-trailing-separator/index.js +17 -0
  114. data/vendor/node_modules/remove-trailing-separator/package.json +37 -0
  115. data/vendor/node_modules/repeat-element/index.js +18 -0
  116. data/vendor/node_modules/repeat-element/package.json +44 -0
  117. data/vendor/node_modules/repeat-string/index.js +70 -0
  118. data/vendor/node_modules/repeat-string/package.json +77 -0
  119. data/vendor/node_modules/rollup-plugin-vue2/dist/rollup-plugin-vue2.common.js +164 -0
  120. data/vendor/node_modules/rollup-plugin-vue2/dist/rollup-plugin-vue2.es.js +160 -0
  121. data/vendor/node_modules/rollup-plugin-vue2/package.json +50 -0
  122. data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.cjs.js +223 -0
  123. data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es.js +214 -0
  124. data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es6.js +217 -0
  125. data/vendor/node_modules/rollup-pluginutils/package.json +40 -0
  126. data/vendor/node_modules/rollup-pluginutils/src/addExtension.js +6 -0
  127. data/vendor/node_modules/rollup-pluginutils/src/attachScopes.js +147 -0
  128. data/vendor/node_modules/rollup-pluginutils/src/createFilter.js +33 -0
  129. data/vendor/node_modules/rollup-pluginutils/src/index.js +4 -0
  130. data/vendor/node_modules/rollup-pluginutils/src/makeLegalIdentifier.js +15 -0
  131. data/vendor/node_modules/rollup-pluginutils/src/utils/ensureArray.js +5 -0
  132. data/vendor/node_modules/vlq/dist/vlq.js +91 -0
  133. data/vendor/node_modules/vlq/package.json +27 -0
  134. data/vendor/node_modules/vlq/src/vlq.js +78 -0
  135. data/vendor/node_modules/vue-template-compiler/browser.js +5237 -0
  136. data/vendor/node_modules/vue-template-compiler/build.js +4835 -0
  137. data/vendor/node_modules/vue-template-compiler/index.js +18 -0
  138. data/vendor/node_modules/vue-template-compiler/package.json +27 -0
  139. data/vendor/node_modules/vue-template-es2015-compiler/buble.js +14112 -0
  140. data/vendor/node_modules/vue-template-es2015-compiler/index.js +24 -0
  141. data/vendor/node_modules/vue-template-es2015-compiler/package.json +28 -0
  142. data/vendor/package.json +9 -0
  143. data/vendor/yarn.lock +268 -0
  144. metadata +242 -0
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "magic-string",
3
+ "description": "Modify strings, generate sourcemaps",
4
+ "author": "Rich Harris",
5
+ "version": "0.19.1",
6
+ "repository": "https://github.com/rich-harris/magic-string",
7
+ "main": "dist/magic-string.cjs.js",
8
+ "module": "dist/magic-string.es.js",
9
+ "jsnext:main": "dist/magic-string.es.js",
10
+ "license": "MIT",
11
+ "dependencies": {
12
+ "vlq": "^0.2.1"
13
+ },
14
+ "devDependencies": {
15
+ "buble": "^0.14.0",
16
+ "codecov.io": "^0.1.6",
17
+ "console-group": "^0.3.2",
18
+ "eslint": "^3.7.1",
19
+ "istanbul": "^0.4.5",
20
+ "mocha": "^3.1.0",
21
+ "remap-istanbul": "^0.6.4",
22
+ "resolve": "^1.1.7",
23
+ "rollup": "^0.36.1",
24
+ "rollup-plugin-buble": "^0.14.0",
25
+ "rollup-plugin-node-resolve": "^2.0.0",
26
+ "rollup-plugin-replace": "^1.1.1",
27
+ "source-map": "^0.5.6",
28
+ "source-map-support": "^0.4.3"
29
+ },
30
+ "keywords": [
31
+ "string",
32
+ "string manipulation",
33
+ "sourcemap",
34
+ "templating",
35
+ "transpilation"
36
+ ],
37
+ "scripts": {
38
+ "test": "mocha",
39
+ "pretest": "npm run build:cjs",
40
+ "pretest-coverage": "npm run build:cjs",
41
+ "test-coverage": "rm -rf coverage/* && istanbul cover --report json node_modules/.bin/_mocha -- -u exports -R spec test/*.js",
42
+ "posttest-coverage": "remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped.json -b dist && remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped.lcov -t lcovonly -b dist && remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped -t html -b dist",
43
+ "ci": "npm run test-coverage && codecov < coverage/coverage-remapped.lcov",
44
+ "build:cjs": "rollup -c",
45
+ "build:es": "rollup -c --environment ES",
46
+ "build:umd": "rollup -c --environment DEPS",
47
+ "build": " npm run build:cjs && npm run build:es && npm run build:umd",
48
+ "prepublish": "rm -rf dist && npm test && npm run build:es && npm run build:umd",
49
+ "lint": "eslint src test",
50
+ "watch:cjs": "rollup -w -c",
51
+ "watch:es": "rollup -w -c --environment ES",
52
+ "watch:umd": "rollup -w -c --environment DEPS",
53
+ "watch": "npm run watch:es"
54
+ },
55
+ "files": [
56
+ "src/*",
57
+ "dist/*",
58
+ "README.md"
59
+ ]
60
+ }
@@ -0,0 +1,263 @@
1
+ import MagicString from './MagicString.js';
2
+ import SourceMap from './utils/SourceMap.js';
3
+ import getRelativePath from './utils/getRelativePath.js';
4
+ import hasOwnProp from './utils/hasOwnProp.js';
5
+ import isObject from './utils/isObject.js';
6
+ import getLocator from './utils/getLocator.js';
7
+ import Mappings from './utils/Mappings.js';
8
+
9
+ export default function Bundle ( options = {} ) {
10
+ this.intro = options.intro || '';
11
+ this.separator = options.separator !== undefined ? options.separator : '\n';
12
+
13
+ this.sources = [];
14
+
15
+ this.uniqueSources = [];
16
+ this.uniqueSourceIndexByFilename = {};
17
+ }
18
+
19
+ Bundle.prototype = {
20
+ addSource ( source ) {
21
+ if ( source instanceof MagicString ) {
22
+ return this.addSource({
23
+ content: source,
24
+ filename: source.filename,
25
+ separator: this.separator
26
+ });
27
+ }
28
+
29
+ if ( !isObject( source ) || !source.content ) {
30
+ throw new Error( 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`' );
31
+ }
32
+
33
+ [ 'filename', 'indentExclusionRanges', 'separator' ].forEach( option => {
34
+ if ( !hasOwnProp.call( source, option ) ) source[ option ] = source.content[ option ];
35
+ });
36
+
37
+ if ( source.separator === undefined ) { // TODO there's a bunch of this sort of thing, needs cleaning up
38
+ source.separator = this.separator;
39
+ }
40
+
41
+ if ( source.filename ) {
42
+ if ( !hasOwnProp.call( this.uniqueSourceIndexByFilename, source.filename ) ) {
43
+ this.uniqueSourceIndexByFilename[ source.filename ] = this.uniqueSources.length;
44
+ this.uniqueSources.push({ filename: source.filename, content: source.content.original });
45
+ } else {
46
+ const uniqueSource = this.uniqueSources[ this.uniqueSourceIndexByFilename[ source.filename ] ];
47
+ if ( source.content.original !== uniqueSource.content ) {
48
+ throw new Error( `Illegal source: same filename (${source.filename}), different contents` );
49
+ }
50
+ }
51
+ }
52
+
53
+ this.sources.push( source );
54
+ return this;
55
+ },
56
+
57
+ append ( str, options ) {
58
+ this.addSource({
59
+ content: new MagicString( str ),
60
+ separator: ( options && options.separator ) || ''
61
+ });
62
+
63
+ return this;
64
+ },
65
+
66
+ clone () {
67
+ const bundle = new Bundle({
68
+ intro: this.intro,
69
+ separator: this.separator
70
+ });
71
+
72
+ this.sources.forEach( source => {
73
+ bundle.addSource({
74
+ filename: source.filename,
75
+ content: source.content.clone(),
76
+ separator: source.separator
77
+ });
78
+ });
79
+
80
+ return bundle;
81
+ },
82
+
83
+ generateMap ( options = {} ) {
84
+ const names = [];
85
+ this.sources.forEach( source => {
86
+ Object.keys( source.content.storedNames ).forEach( name => {
87
+ if ( !~names.indexOf( name ) ) names.push( name );
88
+ });
89
+ });
90
+
91
+ const mappings = new Mappings( options.hires );
92
+
93
+ if ( this.intro ) {
94
+ mappings.advance( this.intro );
95
+ }
96
+
97
+ this.sources.forEach( ( source, i ) => {
98
+ if ( i > 0 ) {
99
+ mappings.advance( this.separator );
100
+ }
101
+
102
+ const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[ source.filename ] : -1;
103
+ const magicString = source.content;
104
+ const locate = getLocator( magicString.original );
105
+
106
+ if ( magicString.intro ) {
107
+ mappings.advance( magicString.intro );
108
+ }
109
+
110
+ magicString.firstChunk.eachNext( chunk => {
111
+ const loc = locate( chunk.start );
112
+
113
+ if ( chunk.intro.length ) mappings.advance( chunk.intro );
114
+
115
+ if ( source.filename ) {
116
+ if ( chunk.edited ) {
117
+ mappings.addEdit( sourceIndex, chunk.content, chunk.original, loc, chunk.storeName ? names.indexOf( chunk.original ) : -1 );
118
+ } else {
119
+ mappings.addUneditedChunk( sourceIndex, chunk, magicString.original, loc, magicString.sourcemapLocations );
120
+ }
121
+ }
122
+
123
+ else {
124
+ mappings.advance( chunk.content );
125
+ }
126
+
127
+ if ( chunk.outro.length ) mappings.advance( chunk.outro );
128
+ });
129
+
130
+ if ( magicString.outro ) {
131
+ mappings.advance( magicString.outro );
132
+ }
133
+ });
134
+
135
+ return new SourceMap({
136
+ file: ( options.file ? options.file.split( /[\/\\]/ ).pop() : null ),
137
+ sources: this.uniqueSources.map( source => {
138
+ return options.file ? getRelativePath( options.file, source.filename ) : source.filename;
139
+ }),
140
+ sourcesContent: this.uniqueSources.map( source => {
141
+ return options.includeContent ? source.content : null;
142
+ }),
143
+ names,
144
+ mappings: mappings.encode()
145
+ });
146
+ },
147
+
148
+ getIndentString () {
149
+ const indentStringCounts = {};
150
+
151
+ this.sources.forEach( source => {
152
+ const indentStr = source.content.indentStr;
153
+
154
+ if ( indentStr === null ) return;
155
+
156
+ if ( !indentStringCounts[ indentStr ] ) indentStringCounts[ indentStr ] = 0;
157
+ indentStringCounts[ indentStr ] += 1;
158
+ });
159
+
160
+ return ( Object.keys( indentStringCounts ).sort( ( a, b ) => {
161
+ return indentStringCounts[a] - indentStringCounts[b];
162
+ })[0] ) || '\t';
163
+ },
164
+
165
+ indent ( indentStr ) {
166
+ if ( !arguments.length ) {
167
+ indentStr = this.getIndentString();
168
+ }
169
+
170
+ if ( indentStr === '' ) return this; // noop
171
+
172
+ let trailingNewline = !this.intro || this.intro.slice( -1 ) === '\n';
173
+
174
+ this.sources.forEach( ( source, i ) => {
175
+ const separator = source.separator !== undefined ? source.separator : this.separator;
176
+ const indentStart = trailingNewline || ( i > 0 && /\r?\n$/.test( separator ) );
177
+
178
+ source.content.indent( indentStr, {
179
+ exclude: source.indentExclusionRanges,
180
+ indentStart//: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator )
181
+ });
182
+
183
+ // TODO this is a very slow way to determine this
184
+ trailingNewline = source.content.toString().slice( 0, -1 ) === '\n';
185
+ });
186
+
187
+ if ( this.intro ) {
188
+ this.intro = indentStr + this.intro.replace( /^[^\n]/gm, ( match, index ) => {
189
+ return index > 0 ? indentStr + match : match;
190
+ });
191
+ }
192
+
193
+ return this;
194
+ },
195
+
196
+ prepend ( str ) {
197
+ this.intro = str + this.intro;
198
+ return this;
199
+ },
200
+
201
+ toString () {
202
+ const body = this.sources.map( ( source, i ) => {
203
+ const separator = source.separator !== undefined ? source.separator : this.separator;
204
+ const str = ( i > 0 ? separator : '' ) + source.content.toString();
205
+
206
+ return str;
207
+ }).join( '' );
208
+
209
+ return this.intro + body;
210
+ },
211
+
212
+ trimLines () {
213
+ return this.trim('[\\r\\n]');
214
+ },
215
+
216
+ trim ( charType ) {
217
+ return this.trimStart( charType ).trimEnd( charType );
218
+ },
219
+
220
+ trimStart ( charType ) {
221
+ const rx = new RegExp( '^' + ( charType || '\\s' ) + '+' );
222
+ this.intro = this.intro.replace( rx, '' );
223
+
224
+ if ( !this.intro ) {
225
+ let source;
226
+ let i = 0;
227
+
228
+ do {
229
+ source = this.sources[i];
230
+
231
+ if ( !source ) {
232
+ break;
233
+ }
234
+
235
+ source.content.trimStart( charType );
236
+ i += 1;
237
+ } while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?
238
+ }
239
+
240
+ return this;
241
+ },
242
+
243
+ trimEnd ( charType ) {
244
+ const rx = new RegExp( ( charType || '\\s' ) + '+$' );
245
+
246
+ let source;
247
+ let i = this.sources.length - 1;
248
+
249
+ do {
250
+ source = this.sources[i];
251
+
252
+ if ( !source ) {
253
+ this.intro = this.intro.replace( rx, '' );
254
+ break;
255
+ }
256
+
257
+ source.content.trimEnd( charType );
258
+ i -= 1;
259
+ } while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?
260
+
261
+ return this;
262
+ }
263
+ };
@@ -0,0 +1,154 @@
1
+ export default function Chunk ( start, end, content ) {
2
+ this.start = start;
3
+ this.end = end;
4
+ this.original = content;
5
+
6
+ this.intro = '';
7
+ this.outro = '';
8
+
9
+ this.content = content;
10
+ this.storeName = false;
11
+ this.edited = false;
12
+
13
+ // we make these non-enumerable, for sanity while debugging
14
+ Object.defineProperties( this, {
15
+ previous: { writable: true, value: null },
16
+ next: { writable: true, value: null }
17
+ });
18
+ }
19
+
20
+ Chunk.prototype = {
21
+ appendLeft ( content ) {
22
+ this.outro += content;
23
+ },
24
+
25
+ appendRight ( content ) {
26
+ this.intro = this.intro + content;
27
+ },
28
+
29
+ clone () {
30
+ const chunk = new Chunk( this.start, this.end, this.original );
31
+
32
+ chunk.intro = this.intro;
33
+ chunk.outro = this.outro;
34
+ chunk.content = this.content;
35
+ chunk.storeName = this.storeName;
36
+ chunk.edited = this.edited;
37
+
38
+ return chunk;
39
+ },
40
+
41
+ contains ( index ) {
42
+ return this.start < index && index < this.end;
43
+ },
44
+
45
+ eachNext ( fn ) {
46
+ let chunk = this;
47
+ while ( chunk ) {
48
+ fn( chunk );
49
+ chunk = chunk.next;
50
+ }
51
+ },
52
+
53
+ eachPrevious ( fn ) {
54
+ let chunk = this;
55
+ while ( chunk ) {
56
+ fn( chunk );
57
+ chunk = chunk.previous;
58
+ }
59
+ },
60
+
61
+ edit ( content, storeName ) {
62
+ this.content = content;
63
+ this.intro = '';
64
+ this.outro = '';
65
+ this.storeName = storeName;
66
+
67
+ this.edited = true;
68
+
69
+ return this;
70
+ },
71
+
72
+ prependLeft ( content ) {
73
+ this.outro = content + this.outro;
74
+ },
75
+
76
+ prependRight ( content ) {
77
+ this.intro = content + this.intro;
78
+ },
79
+
80
+ split ( index ) {
81
+ const sliceIndex = index - this.start;
82
+
83
+ const originalBefore = this.original.slice( 0, sliceIndex );
84
+ const originalAfter = this.original.slice( sliceIndex );
85
+
86
+ this.original = originalBefore;
87
+
88
+ const newChunk = new Chunk( index, this.end, originalAfter );
89
+ newChunk.outro = this.outro;
90
+ this.outro = '';
91
+
92
+ this.end = index;
93
+
94
+ if ( this.edited ) {
95
+ // TODO is this block necessary?...
96
+ newChunk.edit( '', false );
97
+ this.content = '';
98
+ } else {
99
+ this.content = originalBefore;
100
+ }
101
+
102
+ newChunk.next = this.next;
103
+ if ( newChunk.next ) newChunk.next.previous = newChunk;
104
+ newChunk.previous = this;
105
+ this.next = newChunk;
106
+
107
+ return newChunk;
108
+ },
109
+
110
+ toString () {
111
+ return this.intro + this.content + this.outro;
112
+ },
113
+
114
+ trimEnd ( rx ) {
115
+ this.outro = this.outro.replace( rx, '' );
116
+ if ( this.outro.length ) return true;
117
+
118
+ const trimmed = this.content.replace( rx, '' );
119
+
120
+ if ( trimmed.length ) {
121
+ if ( trimmed !== this.content ) {
122
+ this.split( this.start + trimmed.length ).edit( '', false );
123
+ }
124
+
125
+ return true;
126
+ } else {
127
+ this.edit( '', false );
128
+
129
+ this.intro = this.intro.replace( rx, '' );
130
+ if ( this.intro.length ) return true;
131
+ }
132
+ },
133
+
134
+ trimStart ( rx ) {
135
+ this.intro = this.intro.replace( rx, '' );
136
+ if ( this.intro.length ) return true;
137
+
138
+ const trimmed = this.content.replace( rx, '' );
139
+
140
+ if ( trimmed.length ) {
141
+ if ( trimmed !== this.content ) {
142
+ this.split( this.end - trimmed.length );
143
+ this.edit( '', false );
144
+ }
145
+
146
+ return true;
147
+ } else {
148
+ this.edit( '', false );
149
+
150
+ this.outro = this.outro.replace( rx, '' );
151
+ if ( this.outro.length ) return true;
152
+ }
153
+ }
154
+ };