Team Ai
Datasetpublic

Brunobkr/llama.cpp_AlgMor24_github

ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
resolver.js598 linesDownload Raw Back to test
1var path = require('path');2var fs = require('fs');3var test = require('tape');4var resolve = require('../');5var async = require('../async');6 7test('`./async` entry point', function (t) {8    t.equal(resolve, async, '`./async` entry point is the same as `main`');9    t.end();10});11 12test('async foo', function (t) {13    t.plan(12);14    var dir = path.join(__dirname, 'resolver');15 16    resolve('./foo', { basedir: dir }, function (err, res, pkg) {17        if (err) t.fail(err);18        t.equal(res, path.join(dir, 'foo.js'));19        t.equal(pkg && pkg.name, 'resolve');20    });21 22    resolve('./foo.js', { basedir: dir }, function (err, res, pkg) {23        if (err) t.fail(err);24        t.equal(res, path.join(dir, 'foo.js'));25        t.equal(pkg && pkg.name, 'resolve');26    });27 28    resolve('./foo', { basedir: dir, 'package': { main: 'resolver' } }, function (err, res, pkg) {29        if (err) t.fail(err);30        t.equal(res, path.join(dir, 'foo.js'));31        t.equal(pkg && pkg.main, 'resolver');32    });33 34    resolve('./foo.js', { basedir: dir, 'package': { main: 'resolver' } }, function (err, res, pkg) {35        if (err) t.fail(err);36        t.equal(res, path.join(dir, 'foo.js'));37        t.equal(pkg.main, 'resolver');38    });39 40    resolve('./foo', { basedir: dir, filename: path.join(dir, 'baz.js') }, function (err, res) {41        if (err) t.fail(err);42        t.equal(res, path.join(dir, 'foo.js'));43    });44 45    resolve('foo', { basedir: dir }, function (err) {46        t.equal(err.message, "Cannot find module 'foo' from '" + path.resolve(dir) + "'");47        t.equal(err.code, 'MODULE_NOT_FOUND');48    });49 50    // Test that filename is reported as the "from" value when passed.51    resolve('foo', { basedir: dir, filename: path.join(dir, 'baz.js') }, function (err) {52        t.equal(err.message, "Cannot find module 'foo' from '" + path.join(dir, 'baz.js') + "'");53    });54});55 56test('bar', function (t) {57    t.plan(6);58    var dir = path.join(__dirname, 'resolver');59 60    resolve('foo', { basedir: dir + '/bar' }, function (err, res, pkg) {61        if (err) t.fail(err);62        t.equal(res, path.join(dir, 'bar/node_modules/foo/index.js'));63        t.equal(pkg, undefined);64    });65 66    resolve('foo', { basedir: dir + '/bar' }, function (err, res, pkg) {67        if (err) t.fail(err);68        t.equal(res, path.join(dir, 'bar/node_modules/foo/index.js'));69        t.equal(pkg, undefined);70    });71 72    resolve('foo', { basedir: dir + '/bar', 'package': { main: 'bar' } }, function (err, res, pkg) {73        if (err) t.fail(err);74        t.equal(res, path.join(dir, 'bar/node_modules/foo/index.js'));75        t.equal(pkg.main, 'bar');76    });77});78 79test('baz', function (t) {80    t.plan(4);81    var dir = path.join(__dirname, 'resolver');82 83    resolve('./baz', { basedir: dir }, function (err, res, pkg) {84        if (err) t.fail(err);85        t.equal(res, path.join(dir, 'baz/quux.js'));86        t.equal(pkg.main, 'quux.js');87    });88 89    resolve('./baz', { basedir: dir, 'package': { main: 'resolver' } }, function (err, res, pkg) {90        if (err) t.fail(err);91        t.equal(res, path.join(dir, 'baz/quux.js'));92        t.equal(pkg.main, 'quux.js');93    });94});95 96test('biz', function (t) {97    t.plan(24);98    var dir = path.join(__dirname, 'resolver/biz/node_modules');99 100    resolve('./grux', { basedir: dir }, function (err, res, pkg) {101        if (err) t.fail(err);102        t.equal(res, path.join(dir, 'grux/index.js'));103        t.equal(pkg, undefined);104    });105 106    resolve('./grux', { basedir: dir, 'package': { main: 'biz' } }, function (err, res, pkg) {107        if (err) t.fail(err);108        t.equal(res, path.join(dir, 'grux/index.js'));109        t.equal(pkg.main, 'biz');110    });111 112    resolve('./garply', { basedir: dir }, function (err, res, pkg) {113        if (err) t.fail(err);114        t.equal(res, path.join(dir, 'garply/lib/index.js'));115        t.equal(pkg.main, './lib');116    });117 118    resolve('./garply', { basedir: dir, 'package': { main: 'biz' } }, function (err, res, pkg) {119        if (err) t.fail(err);120        t.equal(res, path.join(dir, 'garply/lib/index.js'));121        t.equal(pkg.main, './lib');122    });123 124    resolve('tiv', { basedir: dir + '/grux' }, function (err, res, pkg) {125        if (err) t.fail(err);126        t.equal(res, path.join(dir, 'tiv/index.js'));127        t.equal(pkg, undefined);128    });129 130    resolve('tiv', { basedir: dir + '/grux', 'package': { main: 'grux' } }, function (err, res, pkg) {131        if (err) t.fail(err);132        t.equal(res, path.join(dir, 'tiv/index.js'));133        t.equal(pkg.main, 'grux');134    });135 136    resolve('tiv', { basedir: dir + '/garply' }, function (err, res, pkg) {137        if (err) t.fail(err);138        t.equal(res, path.join(dir, 'tiv/index.js'));139        t.equal(pkg, undefined);140    });141 142    resolve('tiv', { basedir: dir + '/garply', 'package': { main: './lib' } }, function (err, res, pkg) {143        if (err) t.fail(err);144        t.equal(res, path.join(dir, 'tiv/index.js'));145        t.equal(pkg.main, './lib');146    });147 148    resolve('grux', { basedir: dir + '/tiv' }, function (err, res, pkg) {149        if (err) t.fail(err);150        t.equal(res, path.join(dir, 'grux/index.js'));151        t.equal(pkg, undefined);152    });153 154    resolve('grux', { basedir: dir + '/tiv', 'package': { main: 'tiv' } }, function (err, res, pkg) {155        if (err) t.fail(err);156        t.equal(res, path.join(dir, 'grux/index.js'));157        t.equal(pkg.main, 'tiv');158    });159 160    resolve('garply', { basedir: dir + '/tiv' }, function (err, res, pkg) {161        if (err) t.fail(err);162        t.equal(res, path.join(dir, 'garply/lib/index.js'));163        t.equal(pkg.main, './lib');164    });165 166    resolve('garply', { basedir: dir + '/tiv', 'package': { main: 'tiv' } }, function (err, res, pkg) {167        if (err) t.fail(err);168        t.equal(res, path.join(dir, 'garply/lib/index.js'));169        t.equal(pkg.main, './lib');170    });171});172 173test('quux', function (t) {174    t.plan(2);175    var dir = path.join(__dirname, 'resolver/quux');176 177    resolve('./foo', { basedir: dir, 'package': { main: 'quux' } }, function (err, res, pkg) {178        if (err) t.fail(err);179        t.equal(res, path.join(dir, 'foo/index.js'));180        t.equal(pkg.main, 'quux');181    });182});183 184test('normalize', function (t) {185    t.plan(2);186    var dir = path.join(__dirname, 'resolver/biz/node_modules/grux');187 188    resolve('../grux', { basedir: dir }, function (err, res, pkg) {189        if (err) t.fail(err);190        t.equal(res, path.join(dir, 'index.js'));191        t.equal(pkg, undefined);192    });193});194 195test('cup', function (t) {196    t.plan(5);197    var dir = path.join(__dirname, 'resolver');198 199    resolve('./cup', { basedir: dir, extensions: ['.js', '.coffee'] }, function (err, res) {200        if (err) t.fail(err);201        t.equal(res, path.join(dir, 'cup.coffee'));202    });203 204    resolve('./cup.coffee', { basedir: dir }, function (err, res) {205        if (err) t.fail(err);206        t.equal(res, path.join(dir, 'cup.coffee'));207    });208 209    resolve('./cup', { basedir: dir, extensions: ['.js'] }, function (err, res) {210        t.equal(err.message, "Cannot find module './cup' from '" + path.resolve(dir) + "'");211        t.equal(err.code, 'MODULE_NOT_FOUND');212    });213 214    // Test that filename is reported as the "from" value when passed.215    resolve('./cup', { basedir: dir, extensions: ['.js'], filename: path.join(dir, 'cupboard.js') }, function (err, res) {216        t.equal(err.message, "Cannot find module './cup' from '" + path.join(dir, 'cupboard.js') + "'");217    });218});219 220test('mug', function (t) {221    t.plan(3);222    var dir = path.join(__dirname, 'resolver');223 224    resolve('./mug', { basedir: dir }, function (err, res) {225        if (err) t.fail(err);226        t.equal(res, path.join(dir, 'mug.js'));227    });228 229    resolve('./mug', { basedir: dir, extensions: ['.coffee', '.js'] }, function (err, res) {230        if (err) t.fail(err);231        t.equal(res, path.join(dir, '/mug.coffee'));232    });233 234    resolve('./mug', { basedir: dir, extensions: ['.js', '.coffee'] }, function (err, res) {235        t.equal(res, path.join(dir, '/mug.js'));236    });237});238 239test('other path', function (t) {240    t.plan(6);241    var resolverDir = path.join(__dirname, 'resolver');242    var dir = path.join(resolverDir, 'bar');243    var otherDir = path.join(resolverDir, 'other_path');244 245    resolve('root', { basedir: dir, paths: [otherDir] }, function (err, res) {246        if (err) t.fail(err);247        t.equal(res, path.join(resolverDir, 'other_path/root.js'));248    });249 250    resolve('lib/other-lib', { basedir: dir, paths: [otherDir] }, function (err, res) {251        if (err) t.fail(err);252        t.equal(res, path.join(resolverDir, 'other_path/lib/other-lib.js'));253    });254 255    resolve('root', { basedir: dir }, function (err, res) {256        t.equal(err.message, "Cannot find module 'root' from '" + path.resolve(dir) + "'");257        t.equal(err.code, 'MODULE_NOT_FOUND');258    });259 260    resolve('zzz', { basedir: dir, paths: [otherDir] }, function (err, res) {261        t.equal(err.message, "Cannot find module 'zzz' from '" + path.resolve(dir) + "'");262        t.equal(err.code, 'MODULE_NOT_FOUND');263    });264});265 266test('path iterator', function (t) {267    t.plan(2);268 269    var resolverDir = path.join(__dirname, 'resolver');270 271    function exactIterator(x, start, getPackageCandidates, opts) {272        return [path.join(resolverDir, x)];273    }274 275    resolve('baz', { packageIterator: exactIterator }, function (err, res, pkg) {276        if (err) t.fail(err);277        t.equal(res, path.join(resolverDir, 'baz/quux.js'));278        t.equal(pkg && pkg.name, 'baz');279    });280});281 282test('incorrect main', function (t) {283    t.plan(1);284 285    var resolverDir = path.join(__dirname, 'resolver');286    var dir = path.join(resolverDir, 'incorrect_main');287 288    resolve('./incorrect_main', { basedir: resolverDir }, function (err, res, pkg) {289        if (err) t.fail(err);290        t.equal(res, path.join(dir, 'index.js'));291    });292});293 294test('missing index', function (t) {295    t.plan(2);296 297    var resolverDir = path.join(__dirname, 'resolver');298    resolve('./missing_index', { basedir: resolverDir }, function (err, res, pkg) {299        t.ok(err instanceof Error);300        t.equal(err && err.code, 'MODULE_NOT_FOUND', 'error has correct error code');301    });302});303 304test('missing main', function (t) {305    t.plan(1);306 307    var resolverDir = path.join(__dirname, 'resolver');308 309    resolve('./missing_main', { basedir: resolverDir }, function (err, res, pkg) {310        t.equal(err && err.code, 'MODULE_NOT_FOUND', 'error has correct error code');311    });312});313 314test('null main', function (t) {315    t.plan(1);316 317    var resolverDir = path.join(__dirname, 'resolver');318 319    resolve('./null_main', { basedir: resolverDir }, function (err, res, pkg) {320        t.equal(err && err.code, 'MODULE_NOT_FOUND', 'error has correct error code');321    });322});323 324test('main: false', function (t) {325    t.plan(2);326 327    var basedir = path.join(__dirname, 'resolver');328    var dir = path.join(basedir, 'false_main');329    resolve('./false_main', { basedir: basedir }, function (err, res, pkg) {330        if (err) t.fail(err);331        t.equal(332            res,333            path.join(dir, 'index.js'),334            '`"main": false`: resolves to `index.js`'335        );336        t.deepEqual(pkg, {337            name: 'false_main',338            main: false339        });340    });341});342 343test('without basedir', function (t) {344    t.plan(1);345 346    var dir = path.join(__dirname, 'resolver/without_basedir');347    var tester = require(path.join(dir, 'main.js')); // eslint-disable-line global-require348 349    tester(t, function (err, res, pkg) {350        if (err) {351            t.fail(err);352        } else {353            t.equal(res, path.join(dir, 'node_modules/mymodule.js'));354        }355    });356});357 358test('#52 - incorrectly resolves module-paths like "./someFolder/" when there is a file of the same name', function (t) {359    t.plan(2);360 361    var dir = path.join(__dirname, 'resolver');362 363    resolve('./foo', { basedir: path.join(dir, 'same_names') }, function (err, res, pkg) {364        if (err) t.fail(err);365        t.equal(res, path.join(dir, 'same_names/foo.js'));366    });367 368    resolve('./foo/', { basedir: path.join(dir, 'same_names') }, function (err, res, pkg) {369        if (err) t.fail(err);370        t.equal(res, path.join(dir, 'same_names/foo/index.js'));371    });372});373 374test('#211 - incorrectly resolves module-paths like "." when from inside a folder with a sibling file of the same name', function (t) {375    t.plan(2);376 377    var dir = path.join(__dirname, 'resolver');378 379    resolve('./', { basedir: path.join(dir, 'same_names/foo') }, function (err, res, pkg) {380        if (err) t.fail(err);381        t.equal(res, path.join(dir, 'same_names/foo/index.js'));382    });383 384    resolve('.', { basedir: path.join(dir, 'same_names/foo') }, function (err, res, pkg) {385        if (err) t.fail(err);386        t.equal(res, path.join(dir, 'same_names/foo/index.js'));387    });388});389 390test('async: #121 - treating an existing file as a dir when no basedir', function (t) {391    var testFile = path.basename(__filename);392 393    t.test('sanity check', function (st) {394        st.plan(1);395        resolve('./' + testFile, function (err, res, pkg) {396            if (err) t.fail(err);397            st.equal(res, __filename, 'sanity check');398        });399    });400 401    t.test('with a fake directory', function (st) {402        st.plan(4);403 404        resolve('./' + testFile + '/blah', function (err, res, pkg) {405            st.ok(err, 'there is an error');406            st.notOk(res, 'no result');407 408            st.equal(err && err.code, 'MODULE_NOT_FOUND', 'error code matches require.resolve');409            st.equal(410                err && err.message,411                'Cannot find module \'./' + testFile + '/blah\' from \'' + __dirname + '\'',412                'can not find nonexistent module'413            );414            st.end();415        });416    });417 418    t.end();419});420 421test('async dot main', function (t) {422    var start = new Date();423    t.plan(3);424    resolve('./resolver/dot_main', function (err, ret) {425        t.notOk(err);426        t.equal(ret, path.join(__dirname, 'resolver/dot_main/index.js'));427        t.ok(new Date() - start < 50, 'resolve.sync timedout');428        t.end();429    });430});431 432test('async dot slash main', function (t) {433    var start = new Date();434    t.plan(3);435    resolve('./resolver/dot_slash_main', function (err, ret) {436        t.notOk(err);437        t.equal(ret, path.join(__dirname, 'resolver/dot_slash_main/index.js'));438        t.ok(new Date() - start < 50, 'resolve.sync timedout');439        t.end();440    });441});442 443test('not a directory', function (t) {444    t.plan(6);445    var path = './foo';446    resolve(path, { basedir: __filename }, function (err, res, pkg) {447        t.ok(err, 'a non-directory errors');448        t.equal(arguments.length, 1);449        t.equal(res, undefined);450        t.equal(pkg, undefined);451 452        t.equal(err && err.message, 'Cannot find module \'' + path + '\' from \'' + __filename + '\'');453        t.equal(err && err.code, 'MODULE_NOT_FOUND');454    });455});456 457test('non-string "main" field in package.json', function (t) {458    t.plan(5);459 460    var dir = path.join(__dirname, 'resolver');461    resolve('./invalid_main', { basedir: dir }, function (err, res, pkg) {462        t.ok(err, 'errors on non-string main');463        t.equal(err.message, 'package “invalid_main” `main` must be a string');464        t.equal(err.code, 'INVALID_PACKAGE_MAIN');465        t.equal(res, undefined, 'res is undefined');466        t.equal(pkg, undefined, 'pkg is undefined');467    });468});469 470test('non-string "main" field in package.json', function (t) {471    t.plan(5);472 473    var dir = path.join(__dirname, 'resolver');474    resolve('./invalid_main', { basedir: dir }, function (err, res, pkg) {475        t.ok(err, 'errors on non-string main');476        t.equal(err.message, 'package “invalid_main” `main` must be a string');477        t.equal(err.code, 'INVALID_PACKAGE_MAIN');478        t.equal(res, undefined, 'res is undefined');479        t.equal(pkg, undefined, 'pkg is undefined');480    });481});482 483test('browser field in package.json', function (t) {484    t.plan(3);485 486    var dir = path.join(__dirname, 'resolver');487    resolve(488        './browser_field',489        {490            basedir: dir,491            packageFilter: function packageFilter(pkg) {492                if (pkg.browser) {493                    pkg.main = pkg.browser; // eslint-disable-line no-param-reassign494                    delete pkg.browser; // eslint-disable-line no-param-reassign495                }496                return pkg;497            }498        },499        function (err, res, pkg) {500            if (err) t.fail(err);501            t.equal(res, path.join(dir, 'browser_field', 'b.js'));502            t.equal(pkg && pkg.main, 'b');503            t.equal(pkg && pkg.browser, undefined);504        }505    );506});507 508test('absolute paths', function (t) {509    t.plan(4);510 511    var extensionless = __filename.slice(0, -path.extname(__filename).length);512 513    resolve(__filename, function (err, res) {514        t.equal(515            res,516            __filename,517            'absolute path to this file resolves'518        );519    });520    resolve(extensionless, function (err, res) {521        t.equal(522            res,523            __filename,524            'extensionless absolute path to this file resolves'525        );526    });527    resolve(__filename, { basedir: process.cwd() }, function (err, res) {528        t.equal(529            res,530            __filename,531            'absolute path to this file with a basedir resolves'532        );533    });534    resolve(extensionless, { basedir: process.cwd() }, function (err, res) {535        t.equal(536            res,537            __filename,538            'extensionless absolute path to this file with a basedir resolves'539        );540    });541});542 543var malformedDir = path.join(__dirname, 'resolver/malformed_package_json');544test('malformed package.json', { skip: !fs.existsSync(malformedDir) }, function (t) {545    /* eslint operator-linebreak: ["error", "before"], function-paren-newline: "off" */546    t.plan(547        (3 * 3) // 3 sets of 3 assertions in the final callback548        + 2 // 1 readPackage call with malformed package.json549    );550 551    var basedir = malformedDir;552    var expected = path.join(basedir, 'index.js');553 554    resolve('./index.js', { basedir: basedir }, function (err, res, pkg) {555        t.error(err, 'no error');556        t.equal(res, expected, 'malformed package.json is silently ignored');557        t.equal(pkg, undefined, 'malformed package.json gives an undefined `pkg` argument');558    });559 560    resolve(561        './index.js',562        {563            basedir: basedir,564            packageFilter: function (pkg, pkgfile, dir) {565                t.fail('should not reach here');566            }567        },568        function (err, res, pkg) {569            t.error(err, 'with packageFilter: no error');570            t.equal(res, expected, 'with packageFilter: malformed package.json is silently ignored');571            t.equal(pkg, undefined, 'with packageFilter: malformed package.json gives an undefined `pkg` argument');572        }573    );574 575    resolve(576        './index.js',577        {578            basedir: basedir,579            readPackage: function (readFile, pkgfile, cb) {580                t.equal(pkgfile, path.join(basedir, 'package.json'), 'readPackageSync: `pkgfile` is package.json path');581                readFile(pkgfile, function (err, result) {582                    try {583                        cb(null, JSON.parse(result));584                    } catch (e) {585                        t.ok(e instanceof SyntaxError, 'readPackage: malformed package.json parses as a syntax error');586                        cb(null);587                    }588                });589            }590        },591        function (err, res, pkg) {592            t.error(err, 'with readPackage: no error');593            t.equal(res, expected, 'with readPackage: malformed package.json is silently ignored');594            t.equal(pkg, undefined, 'with readPackage: malformed package.json gives an undefined `pkg` argument');595        }596    );597});598 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai