{"library":"path-loader","title":"Path Loader","description":"path-loader is a JavaScript utility library designed to provide a unified API for loading content from both file paths and URLs, operating seamlessly across Node.js and browser environments. It currently supports `http`/`https` loaders for remote resources (default in browsers and for URLs in Node.js) and a `file` loader specifically for Node.js. While the README mentions future plans for a pluggable infrastructure, the package has not seen active development since its last release, version 1.0.12, in August 2016. Its release cadence is effectively inactive. The library differentiates itself by abstracting away environment-specific data loading mechanisms (e.g., XMLHttpRequest/fetch in browsers, `fs` or `http` modules in Node.js) behind a single `load` interface, utilizing `superagent` for AJAX functionality and `native-promise-only` for Promise polyfilling.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install path-loader"],"cli":null},"imports":["const loader = require('path-loader');","<!-- In HTML after script tag -->\n<script src=\"path-loader.js\"></script>\n<script>\n  pathLoader.load('https://example.com/data.json')\n    .then(console.log)\n    .catch(console.error);\n</script>","const { load } = require('path-loader');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const loader = require('path-loader');\n\n// Example: Loading content from a remote URL\nloader.load('https://jsonplaceholder.typicode.com/posts/1')\n  .then(function (res) {\n    console.log('Successfully loaded remote data:');\n    console.log(JSON.parse(res.text));\n  })\n  .catch(function (err) {\n    console.error('Error loading remote data:', err.message);\n  });\n\n// Example: Loading a local file (Node.js only)\n// This will likely fail if the file does not exist or permissions are incorrect.\n// In a real application, replace 'package.json' with a valid local path.\nif (typeof window === 'undefined') { // Check if running in Node.js\n  loader.load('./package.json')\n    .then(function (res) {\n      console.log('\\nSuccessfully loaded local file:');\n      console.log(JSON.parse(res.text));\n    })\n    .catch(function (err) {\n      console.error('\\nError loading local file:', err.message);\n    });\n}","lang":"javascript","description":"Demonstrates loading JSON content from a remote URL (works in browser and Node.js) and a local file (Node.js only) using the unified `loader.load` API.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}