mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-21 05:40:29 +08:00
79 lines
2.5 KiB
JavaScript
79 lines
2.5 KiB
JavaScript
'use strict';Object.defineProperty(exports,Symbol.toStringTag,{value:'Module'});const processLine=require('../../_virtual/process-line.cjs'),require$$0=require('node:stream/web');var hasRequiredProcessLine;
|
|
|
|
function requireProcessLine () {
|
|
if (hasRequiredProcessLine) return processLine.__exports;
|
|
hasRequiredProcessLine = 1;
|
|
(function (exports) {
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
function _export(target, all) {
|
|
for(var name in all)Object.defineProperty(target, name, {
|
|
enumerable: true,
|
|
get: all[name]
|
|
});
|
|
}
|
|
_export(exports, {
|
|
ProcessLineStream: function() {
|
|
return ProcessLineStream;
|
|
},
|
|
processLine: function() {
|
|
return processLine;
|
|
}
|
|
});
|
|
const _web = require$$0;
|
|
function processLine(line) {
|
|
const trimmed = line.trim();
|
|
if (trimmed.length === 0) {
|
|
return null;
|
|
}
|
|
const line_0 = trimmed.charCodeAt(0);
|
|
if (// line_0 === 32 /** [space] */
|
|
// || line_0 === 13 /** \r */
|
|
// || line_0 === 10 /** \n */
|
|
line_0 === 33 /** ! */ || line_0 === 47 /** / */ && trimmed.charCodeAt(1) === 47 /** / */ ) {
|
|
return null;
|
|
}
|
|
if (line_0 === 35 /** # */ ) {
|
|
if (trimmed.charCodeAt(1) !== 35 /** # */ ) {
|
|
// # Comment
|
|
return null;
|
|
}
|
|
if (trimmed.charCodeAt(2) === 35 /** # */ && trimmed.charCodeAt(3) === 35) {
|
|
// ################## EOF ##################
|
|
return null;
|
|
}
|
|
/**
|
|
* AdGuard Filter can be:
|
|
*
|
|
* ##.class
|
|
* ##tag.class
|
|
* ###id
|
|
*/ }
|
|
return trimmed;
|
|
}
|
|
class ProcessLineStream extends _web.TransformStream {
|
|
// private __buf = '';
|
|
constructor(){
|
|
super({
|
|
transform (l, controller) {
|
|
const line = processLine(l);
|
|
if (line) {
|
|
controller.enqueue(line);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
} // export class ProcessLineNodeStream extends Transform {
|
|
// _transform(chunk: string, encoding: BufferEncoding, callback: TransformCallback) {
|
|
// // Convert chunk to string and then to uppercase
|
|
// const upperCased = chunk.toUpperCase();
|
|
// // Push transformed data to readable side
|
|
// this.push(upperCased);
|
|
// // Call callback when done
|
|
// callback();
|
|
// }
|
|
// }
|
|
} (processLine.__exports));
|
|
return processLine.__exports;
|
|
}exports.__require=requireProcessLine; |