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
wrap-idb-value.cjs192 linesDownload Raw Back to build
1'use strict';2 3const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);4 5let idbProxyableTypes;6let cursorAdvanceMethods;7// This is a function to prevent it throwing up in node environments.8function getIdbProxyableTypes() {9    return (idbProxyableTypes ||10        (idbProxyableTypes = [11            IDBDatabase,12            IDBObjectStore,13            IDBIndex,14            IDBCursor,15            IDBTransaction,16        ]));17}18// This is a function to prevent it throwing up in node environments.19function getCursorAdvanceMethods() {20    return (cursorAdvanceMethods ||21        (cursorAdvanceMethods = [22            IDBCursor.prototype.advance,23            IDBCursor.prototype.continue,24            IDBCursor.prototype.continuePrimaryKey,25        ]));26}27const cursorRequestMap = new WeakMap();28const transactionDoneMap = new WeakMap();29const transactionStoreNamesMap = new WeakMap();30const transformCache = new WeakMap();31const reverseTransformCache = new WeakMap();32function promisifyRequest(request) {33    const promise = new Promise((resolve, reject) => {34        const unlisten = () => {35            request.removeEventListener('success', success);36            request.removeEventListener('error', error);37        };38        const success = () => {39            resolve(wrap(request.result));40            unlisten();41        };42        const error = () => {43            reject(request.error);44            unlisten();45        };46        request.addEventListener('success', success);47        request.addEventListener('error', error);48    });49    promise50        .then((value) => {51        // Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval52        // (see wrapFunction).53        if (value instanceof IDBCursor) {54            cursorRequestMap.set(value, request);55        }56        // Catching to avoid "Uncaught Promise exceptions"57    })58        .catch(() => { });59    // This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This60    // is because we create many promises from a single IDBRequest.61    reverseTransformCache.set(promise, request);62    return promise;63}64function cacheDonePromiseForTransaction(tx) {65    // Early bail if we've already created a done promise for this transaction.66    if (transactionDoneMap.has(tx))67        return;68    const done = new Promise((resolve, reject) => {69        const unlisten = () => {70            tx.removeEventListener('complete', complete);71            tx.removeEventListener('error', error);72            tx.removeEventListener('abort', error);73        };74        const complete = () => {75            resolve();76            unlisten();77        };78        const error = () => {79            reject(tx.error || new DOMException('AbortError', 'AbortError'));80            unlisten();81        };82        tx.addEventListener('complete', complete);83        tx.addEventListener('error', error);84        tx.addEventListener('abort', error);85    });86    // Cache it for later retrieval.87    transactionDoneMap.set(tx, done);88}89let idbProxyTraps = {90    get(target, prop, receiver) {91        if (target instanceof IDBTransaction) {92            // Special handling for transaction.done.93            if (prop === 'done')94                return transactionDoneMap.get(target);95            // Polyfill for objectStoreNames because of Edge.96            if (prop === 'objectStoreNames') {97                return target.objectStoreNames || transactionStoreNamesMap.get(target);98            }99            // Make tx.store return the only store in the transaction, or undefined if there are many.100            if (prop === 'store') {101                return receiver.objectStoreNames[1]102                    ? undefined103                    : receiver.objectStore(receiver.objectStoreNames[0]);104            }105        }106        // Else transform whatever we get back.107        return wrap(target[prop]);108    },109    set(target, prop, value) {110        target[prop] = value;111        return true;112    },113    has(target, prop) {114        if (target instanceof IDBTransaction &&115            (prop === 'done' || prop === 'store')) {116            return true;117        }118        return prop in target;119    },120};121function replaceTraps(callback) {122    idbProxyTraps = callback(idbProxyTraps);123}124function wrapFunction(func) {125    // Due to expected object equality (which is enforced by the caching in `wrap`), we126    // only create one new func per func.127    // Edge doesn't support objectStoreNames (booo), so we polyfill it here.128    if (func === IDBDatabase.prototype.transaction &&129        !('objectStoreNames' in IDBTransaction.prototype)) {130        return function (storeNames, ...args) {131            const tx = func.call(unwrap(this), storeNames, ...args);132            transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);133            return wrap(tx);134        };135    }136    // Cursor methods are special, as the behaviour is a little more different to standard IDB. In137    // IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the138    // cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense139    // with real promises, so each advance methods returns a new promise for the cursor object, or140    // undefined if the end of the cursor has been reached.141    if (getCursorAdvanceMethods().includes(func)) {142        return function (...args) {143            // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use144            // the original object.145            func.apply(unwrap(this), args);146            return wrap(cursorRequestMap.get(this));147        };148    }149    return function (...args) {150        // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use151        // the original object.152        return wrap(func.apply(unwrap(this), args));153    };154}155function transformCachableValue(value) {156    if (typeof value === 'function')157        return wrapFunction(value);158    // This doesn't return, it just creates a 'done' promise for the transaction,159    // which is later returned for transaction.done (see idbObjectHandler).160    if (value instanceof IDBTransaction)161        cacheDonePromiseForTransaction(value);162    if (instanceOfAny(value, getIdbProxyableTypes()))163        return new Proxy(value, idbProxyTraps);164    // Return the same value back if we're not going to transform it.165    return value;166}167function wrap(value) {168    // We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because169    // IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.170    if (value instanceof IDBRequest)171        return promisifyRequest(value);172    // If we've already transformed this value before, reuse the transformed value.173    // This is faster, but it also provides object equality.174    if (transformCache.has(value))175        return transformCache.get(value);176    const newValue = transformCachableValue(value);177    // Not all types are transformed.178    // These may be primitive types, so they can't be WeakMap keys.179    if (newValue !== value) {180        transformCache.set(value, newValue);181        reverseTransformCache.set(newValue, value);182    }183    return newValue;184}185const unwrap = (value) => reverseTransformCache.get(value);186 187exports.instanceOfAny = instanceOfAny;188exports.replaceTraps = replaceTraps;189exports.reverseTransformCache = reverseTransformCache;190exports.unwrap = unwrap;191exports.wrap = wrap;192 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai