Uname: Linux webm016.cluster127.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 54.36.31.145
Your Ip: 216.73.216.182
User: homesquasz (91404) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : brfs.js
var staticModule = require('../');
var test = require('tape');
var concat = require('concat-stream');
var quote = require('quote-stream');
var fs = require('fs');
var path = require('path');
var vm = require('vm');

test('readFileSync', function (t) {
    t.plan(2);
    var sm = staticModule({
        fs: {
            readFileSync: function (file) {
                return fs.createReadStream(file).pipe(quote());
            }
        }
    }, { vars: { __dirname: path.join(__dirname, 'brfs') } });
    readStream('source.js').pipe(sm).pipe(concat(function (body) {
        t.equal(body.toString('utf8'),
            '\nvar src = "beep boop\\n";'
            + '\nconsole.log(src);\n'
        );
        vm.runInNewContext(body.toString('utf8'), {
            console: { log: log }
        });
        function log (msg) { t.equal(msg, 'beep boop\n') }
    }));
});

test('readFileSync empty', function (t) {
    t.plan(1);
    var sm = staticModule({
        fs: {
            readFileSync: function (file) {
                return fs.createReadStream(file).pipe(quote());
            }
        }
    }, { vars: { __dirname: path.join(__dirname, 'brfs') } });
    readStream('empty.js').pipe(sm).pipe(concat(function (body) {
        t.equal(body.toString('utf8'), '');
    }));
});

test('readFileSync attribute', function (t) {
    t.plan(2);
    var sm = staticModule({
        fs: {
            readFileSync: function (file) {
                return fs.createReadStream(file).pipe(quote());
            }
        }
    }, { vars: { __dirname: path.join(__dirname, 'brfs') } });
    readStream('attribute.js').pipe(sm).pipe(concat(function (body) {
        t.equal(body.toString('utf8'),
            '\nvar src = "beep boop\\n";'
            + '\nconsole.log(src);\n'
        );
        vm.runInNewContext(body.toString('utf8'), {
            console: { log: log }
        });
        function log (msg) { t.equal(msg, 'beep boop\n') }
    }));
});

test('readFileSync attribute with multiple vars', function (t) {
    t.plan(2);
    var sm = staticModule({
        fs: {
            readFileSync: function (file) {
                return fs.createReadStream(file).pipe(quote());
            }
        }
    }, { vars: { __dirname: path.join(__dirname, 'brfs') } });
    readStream('attribute_vars.js').pipe(sm).pipe(concat(function (body) {
        t.equal(body.toString('utf8'),
            'var x = 5, y = 2;'
            + '\nvar src = "beep boop\\n";'
            + '\nconsole.log(src);\n'
        );
        vm.runInNewContext(body.toString('utf8'), {
            console: { log: log }
        });
        function log (msg) { t.equal(msg, 'beep boop\n') }
    }));
});

test('readFileSync attribute with multiple require vars', function (t) {
    t.plan(2);
    var sm = staticModule({
        fs: {
            readFileSync: function (file) {
                return fs.createReadStream(file).pipe(quote());
            }
        }
    }, { vars: { __dirname: path.join(__dirname, 'brfs') } });
    readStream('multi_require.js').pipe(sm).pipe(concat(function (body) {
        t.equal(body.toString('utf8'),
            'var x = 5;'
            + '\nvar src = "beep boop\\n";'
            + '\nconsole.log(src);\n'
        );
        vm.runInNewContext(body.toString('utf8'), {
            console: { log: log }
        });
        function log (msg) { t.equal(msg, 'beep boop\n') }
    }));
});

test('readFileSync attribute with multiple require vars including an uninitalized var', function (t) {
    t.plan(2);
    var sm = staticModule({
        fs: {
            readFileSync: function (file) {
                return fs.createReadStream(file).pipe(quote());
            }
        }
    }, { vars: { __dirname: path.join(__dirname, 'brfs') } });
    readStream('multi_require_with_uninitialized.js').pipe(sm).pipe(concat(function (body) {
        t.equal(body.toString('utf8'),
            'var x;'
            + '\nvar src = "beep boop\\n";'
            + '\nconsole.log(src);\n'
        );
        vm.runInNewContext(body.toString('utf8'), {
            console: { log: log }
        });
        function log (msg) { t.equal(msg, 'beep boop\n') }
    }));
});

test('readFileSync attribute with multiple require vars x5', function (t) {
    t.plan(2);
    var sm = staticModule({
        fs: {
            readFileSync: function (file) {
                return fs.createReadStream(file).pipe(quote());
            }
        }
    }, { vars: { __dirname: path.join(__dirname, 'brfs') } });
    readStream('x5.js').pipe(sm).pipe(concat(function (body) {
        t.equal(body.toString('utf8'),
            'var a = 1, b = 2, c = 3, d = 4, '
            + 'src = "beep boop\\n",\n'
            + '  e = 5\n'
            + ';\n'
            + 'console.log(src);\n'
        );
        vm.runInNewContext(body.toString('utf8'), {
            console: { log: log }
        });
        function log (msg) { t.equal(msg, 'beep boop\n') }
    }));
});

test('readFileSync with bracket notation', function (t) {
    t.plan(2);
    var sm = staticModule({
        fs: {
            readFileSync: function (file) {
                return fs.createReadStream(file).pipe(quote());
            }
        }
    }, { vars: { __dirname: path.join(__dirname, 'brfs') } });
    readStream('brackets.js').pipe(sm).pipe(concat(function (body) {
        t.equal(body.toString('utf8'),
            '\nvar src = "beep boop\\n";'
            + '\nconsole.log(src);\n'
        );
        vm.runInNewContext(body.toString('utf8'), {
            console: { log: log }
        });
        function log (msg) { t.equal(msg, 'beep boop\n') }
    }));
});

test('readFileSync attribute bracket notation', function (t) {
    t.plan(2);
    var sm = staticModule({
        fs: {
            readFileSync: function (file) {
                return fs.createReadStream(file).pipe(quote());
            }
        }
    }, { vars: { __dirname: path.join(__dirname, 'brfs') } });
    readStream('attribute_brackets.js').pipe(sm).pipe(concat(function (body) {
        t.equal(body.toString('utf8'),
            '\nvar src = "beep boop\\n";'
            + '\nconsole.log(src);\n'
        );
        vm.runInNewContext(body.toString('utf8'), {
            console: { log: log }
        });
        function log (msg) { t.equal(msg, 'beep boop\n') }
    }));
});

function readStream (file) {
    return fs.createReadStream(path.join(__dirname, 'brfs', file));
}
© 2026 GrazzMean
Page non trouvée – APK Comptoir Hammami
Jannah Theme License is not validated, Go to the theme options page to validate the license, You need a single license for each domain name.

404 :(

Oups ! Cette page est introuvable.

Il semble que nous ne puissions pas trouver ce que vous cherchez. Peut-être qu'une recherche pourrait vous aider.

Bouton retour en haut de la page