Equation.js/dist/readstream.js

53 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

2015-04-20 09:28:11 +00:00
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports['default'] = function (string) {
var i = 0,
buffer = [];
return {
next: function next() {
buffer.push(string[i]);
if (i >= string.length) {
return null;
2015-04-20 09:55:41 +00:00
}
return string[i++];
2015-04-20 09:28:11 +00:00
},
current: function current() {
return string[i - 1];
},
index: function index() {
return i - 1;
},
to: function to(n) {
var temp = '';
var dest = i + n;
for (i = i; i < dest; ++i) {
temp += [string[i]];
}
return temp;
},
drain: function drain() {
return buffer.splice(0, buffer.length);
},
2020-06-09 13:58:42 +00:00
replace: function replace(start, end, _replace) {
2015-04-20 09:28:11 +00:00
var temp = string.split('');
2020-06-09 13:58:42 +00:00
temp.splice(start, end, _replace);
2015-04-20 09:28:11 +00:00
string = temp.join('');
i = i - (end - start);
2020-06-09 13:58:42 +00:00
},
2015-04-20 09:28:11 +00:00
go: function go(n) {
i += n;
},
all: function all() {
return string;
}
};
};
2020-06-09 13:58:42 +00:00
module.exports = exports['default'];