Download pool/shard008/JavaScript/0050153_index.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard008/JavaScript/0050153_index.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard008/JavaScript/0050153_index.js
-
curl -L -o 0050153_index.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard008/JavaScript/0050153_index.js
1.84 kB
| var _ = require('lodash'); | |
| var vm = require('vm'); | |
| var path = require('path'); | |
| var fs = require('fs'); | |
| var fromJson = (s) => { | |
| try{ return JSON.parse(s); }catch(ex){ | |
| console.warn(ex); | |
| } | |
| return null; | |
| }; | |
| var regexpJSON = /\.json$/i; | |
| var regexpCustomModule = /^(\.+|\w+:)?[\/\\]/i; | |
| var provider = module.exports = ( | |
| root = '.', | |
| vmOptions = {}, | |
| cachedModules = {} | |
| ) => { | |
| var provide = (name, sandbox = {}, uncache = false, _vm = {}) => { | |
| var cachedModules = provide.cachedModules; | |
| if(!name.match(regexpCustomModule))return require(name); | |
| var filename = path.isAbsolute(name) ? name : path.join(root, name); | |
| if(!uncache && cachedModules[filename])return cachedModules[filename]; | |
| var code = ''; | |
| try{ | |
| code = fs.readFileSync(filename, 'utf8'); | |
| }catch(ex){console.warn(ex); return null;} | |
| if(name.match(regexpJSON))return fromJson(code); | |
| var exports = {}; | |
| var module = {exports: exports}; | |
| var dirname = path.dirname(filename); | |
| var _sandbox = { | |
| __filename: filename, | |
| __dirname: dirname, | |
| module: module, | |
| exports: exports, | |
| Promise, JSON, console, Math, | |
| setInterval, setTimeout, setImmediate, | |
| require: provider(dirname, vmOptions, cachedModules) | |
| }; | |
| var _vmOptions = _.extend({}, vmOptions, _vm); | |
| _.extend(_sandbox, sandbox); | |
| try{ | |
| (new vm.Script(code)).runInContext(new vm.createContext(_sandbox), _vmOptions); | |
| }catch(ex){console.warn(filename, ':', ex);} | |
| if(!uncache)cachedModules[filename] = module.exports; | |
| return module.exports; | |
| }; | |
| provide.clearCache = () => _.clear(provide.cachedModules); | |
| provide.cachedModules = cachedModules; | |
| return provide; | |
| }; |