Socket
Socket
Sign inDemoInstall

@cobalt-engine/loader

Package Overview
Dependencies
1
Maintainers
6
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @cobalt-engine/loader

Module encapsulates AJAX file loading and caching using promises.


Version published
Weekly downloads
81
increased by170%
Maintainers
6
Install size
19.9 kB
Created
Weekly downloads
 

Readme

Source

Loader

Module encapsulates AJAX file loading and caching using promises.

Cobalt uses Bluebird promise library. You can find documentation for it on this page.

Use this module for loading of all JSON files in you presentation.

Install

Loader is a part of core functionality so you don't need to install it.

API

Methods:

  • load(url) - url - path to file (string). Returns Promise that resolves when file has loaded

  • loadJSON(url, reviewer) - url - path to file (string). reviewer - function that will passed to JSON.parse when file is loaded. Returns Promise that resolves when file has loaded. If file can't be loaded or parsed with reviewer function promise fill be fulfilled with empty object and warning will be logged to console:

      "File can't be loaded or parsed: `url`"
    

Example

Controller code:

var loader = require('loader');

module.exports = function(scope) {
	loader.loadJSON('i18n/en/common.json').then(function(result) {
		console.log(result);
	});
}

As a result object stored in file i18n/en/common.json will be logged to console.

FAQs

Last updated on 16 Apr 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc