Revamping to matrix style
This commit is contained in:
21
node_modules/@emmetio/stream-reader/LICENSE
generated
vendored
Normal file
21
node_modules/@emmetio/stream-reader/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Emmet.io
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
130
node_modules/@emmetio/stream-reader/dist/stream-reader.cjs.js
generated
vendored
Normal file
130
node_modules/@emmetio/stream-reader/dist/stream-reader.cjs.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* A streaming, character code-based string reader
|
||||
*/
|
||||
class StreamReader {
|
||||
constructor(string, start, end) {
|
||||
if (end == null && typeof string === 'string') {
|
||||
end = string.length;
|
||||
}
|
||||
|
||||
this.string = string;
|
||||
this.pos = this.start = start || 0;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true only if the stream is at the end of the file.
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
eof() {
|
||||
return this.pos >= this.end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new stream instance which is limited to given `start` and `end`
|
||||
* range. E.g. its `eof()` method will look at `end` property, not actual
|
||||
* stream end
|
||||
* @param {Point} start
|
||||
* @param {Point} end
|
||||
* @return {StreamReader}
|
||||
*/
|
||||
limit(start, end) {
|
||||
return new this.constructor(this.string, start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next character code in the stream without advancing it.
|
||||
* Will return NaN at the end of the file.
|
||||
* @returns {Number}
|
||||
*/
|
||||
peek() {
|
||||
return this.string.charCodeAt(this.pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next character in the stream and advances it.
|
||||
* Also returns <code>undefined</code> when no more characters are available.
|
||||
* @returns {Number}
|
||||
*/
|
||||
next() {
|
||||
if (this.pos < this.string.length) {
|
||||
return this.string.charCodeAt(this.pos++);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* `match` can be a character code or a function that takes a character code
|
||||
* and returns a boolean. If the next character in the stream 'matches'
|
||||
* the given argument, it is consumed and returned.
|
||||
* Otherwise, `false` is returned.
|
||||
* @param {Number|Function} match
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
eat(match) {
|
||||
const ch = this.peek();
|
||||
const ok = typeof match === 'function' ? match(ch) : ch === match;
|
||||
|
||||
if (ok) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repeatedly calls <code>eat</code> with the given argument, until it
|
||||
* fails. Returns <code>true</code> if any characters were eaten.
|
||||
* @param {Object} match
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
eatWhile(match) {
|
||||
const start = this.pos;
|
||||
while (!this.eof() && this.eat(match)) {}
|
||||
return this.pos !== start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backs up the stream n characters. Backing it up further than the
|
||||
* start of the current token will cause things to break, so be careful.
|
||||
* @param {Number} n
|
||||
*/
|
||||
backUp(n) {
|
||||
this.pos -= (n || 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string between the start of the current token and the
|
||||
* current stream position.
|
||||
* @returns {String}
|
||||
*/
|
||||
current() {
|
||||
return this.substring(this.start, this.pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns substring for given range
|
||||
* @param {Number} start
|
||||
* @param {Number} [end]
|
||||
* @return {String}
|
||||
*/
|
||||
substring(start, end) {
|
||||
return this.string.slice(start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates error object with current stream state
|
||||
* @param {String} message
|
||||
* @return {Error}
|
||||
*/
|
||||
error(message) {
|
||||
const err = new Error(`${message} at char ${this.pos + 1}`);
|
||||
err.originalMessage = message;
|
||||
err.pos = this.pos;
|
||||
err.string = this.string;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = StreamReader;
|
||||
128
node_modules/@emmetio/stream-reader/dist/stream-reader.es.js
generated
vendored
Normal file
128
node_modules/@emmetio/stream-reader/dist/stream-reader.es.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* A streaming, character code-based string reader
|
||||
*/
|
||||
class StreamReader {
|
||||
constructor(string, start, end) {
|
||||
if (end == null && typeof string === 'string') {
|
||||
end = string.length;
|
||||
}
|
||||
|
||||
this.string = string;
|
||||
this.pos = this.start = start || 0;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true only if the stream is at the end of the file.
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
eof() {
|
||||
return this.pos >= this.end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new stream instance which is limited to given `start` and `end`
|
||||
* range. E.g. its `eof()` method will look at `end` property, not actual
|
||||
* stream end
|
||||
* @param {Point} start
|
||||
* @param {Point} end
|
||||
* @return {StreamReader}
|
||||
*/
|
||||
limit(start, end) {
|
||||
return new this.constructor(this.string, start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next character code in the stream without advancing it.
|
||||
* Will return NaN at the end of the file.
|
||||
* @returns {Number}
|
||||
*/
|
||||
peek() {
|
||||
return this.string.charCodeAt(this.pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next character in the stream and advances it.
|
||||
* Also returns <code>undefined</code> when no more characters are available.
|
||||
* @returns {Number}
|
||||
*/
|
||||
next() {
|
||||
if (this.pos < this.string.length) {
|
||||
return this.string.charCodeAt(this.pos++);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* `match` can be a character code or a function that takes a character code
|
||||
* and returns a boolean. If the next character in the stream 'matches'
|
||||
* the given argument, it is consumed and returned.
|
||||
* Otherwise, `false` is returned.
|
||||
* @param {Number|Function} match
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
eat(match) {
|
||||
const ch = this.peek();
|
||||
const ok = typeof match === 'function' ? match(ch) : ch === match;
|
||||
|
||||
if (ok) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repeatedly calls <code>eat</code> with the given argument, until it
|
||||
* fails. Returns <code>true</code> if any characters were eaten.
|
||||
* @param {Object} match
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
eatWhile(match) {
|
||||
const start = this.pos;
|
||||
while (!this.eof() && this.eat(match)) {}
|
||||
return this.pos !== start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backs up the stream n characters. Backing it up further than the
|
||||
* start of the current token will cause things to break, so be careful.
|
||||
* @param {Number} n
|
||||
*/
|
||||
backUp(n) {
|
||||
this.pos -= (n || 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string between the start of the current token and the
|
||||
* current stream position.
|
||||
* @returns {String}
|
||||
*/
|
||||
current() {
|
||||
return this.substring(this.start, this.pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns substring for given range
|
||||
* @param {Number} start
|
||||
* @param {Number} [end]
|
||||
* @return {String}
|
||||
*/
|
||||
substring(start, end) {
|
||||
return this.string.slice(start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates error object with current stream state
|
||||
* @param {String} message
|
||||
* @return {Error}
|
||||
*/
|
||||
error(message) {
|
||||
const err = new Error(`${message} at char ${this.pos + 1}`);
|
||||
err.originalMessage = message;
|
||||
err.pos = this.pos;
|
||||
err.string = this.string;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
export default StreamReader;
|
||||
33
node_modules/@emmetio/stream-reader/package.json
generated
vendored
Normal file
33
node_modules/@emmetio/stream-reader/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@emmetio/stream-reader",
|
||||
"version": "2.2.0",
|
||||
"description": "Reads text as stream",
|
||||
"main": "dist/stream-reader.cjs.js",
|
||||
"module": "dist/stream-reader.es.js",
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"build": "rollup -c",
|
||||
"prepublish": "npm run test && npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/emmetio/stream-reader.git"
|
||||
},
|
||||
"keywords": [
|
||||
"emmet",
|
||||
"stream",
|
||||
"reader"
|
||||
],
|
||||
"author": "Sergey Chikuyonok <serge.che@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/emmetio/stream-reader/issues"
|
||||
},
|
||||
"homepage": "https://github.com/emmetio/stream-reader#readme",
|
||||
"devDependencies": {
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.18.0",
|
||||
"babel-register": "^6.18.0",
|
||||
"mocha": "^3.2.0",
|
||||
"rollup": "^0.41.1"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user