Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

orgy

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

orgy

Async file and script loader that works both in the browser and in nodejs / io.js.

  • 2.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-78.57%
Maintainers
1
Weekly downloads
 
Created
Source

Orgy

Build Status Dependency Status NPM version

Promises library that supports queues of file requests.

  • Requires nodejs > 4.0.0.

For nodejs versions 0.0.10 - 0.0.12:

npm install orgy@2.0.7

Documentation:

View the API reference here.

Installation:

  • Nodejs
npm install orgy
  • Browser (attached to window object)
<script src="/dist/orgy.min.js"></script>
<script>
var def = Orgy.deferred();
...
</script>
  • Browser (via browserify)
<script src="/dist/orgy.bundle.min.js"></script>
<script>
var Orgy = require("orgy");
var def = Orgy.deferred();
...
</script>

Example:

  • Fetch a group of resources asynchronously, then return manipulated results down the chain.
const Orgy = require("orgy");

const q = Orgy.queue([
  {
    type : "json",
    url : "data/data1.json"
  },
  {
    type : "json",
    url : "data/data2.json"
  },
  {
    type : "css",
    url : "data/sample.css"
  }
],{
  //Set an id for the queue, so can reference it in other contexts (optional).
  id : "q1" 
});

//Done can be called async and out of order.
q.done(function(r,deferred,last){
  console.log(last); // 2
});

// If a then function returns a value, that value is passed down to any
// subsequent then() or done() functions.
q.then(function(r){
  console.log(r); //Dependency values.
  return 1;
});

q.then(function(r,deferred,last){
  console.log(last); // 1
  return 2;
});
// To reference the queue above outside of the local scope:
const Orgy = require("orgy");
const q = Orgy.get("q1");

Features:

  • Browser and nodej / iojs compatible.

  • Handles a variety of dependency types and automatically converts them into promises.

    • javascript files
    • css files
    • timers
    • all other file types handled as text
  • Queues can be held back from settling after their dependencies have resolved by a resolver method.

  • When then() returns a value that value is passed down the execution chain.

  • When then() returns an unsettled instance (deferred/queue), further execution on the callback chain is halted until that instance resolves. The deferred is then passed to the next tick of the callback chain, where its return value can be accessed.

Running tests:

grunt t

Todo:

  • Add optional retry configuration setting when remote requests rejected due non 200 HTTP response?
  • Extend deferred, queue from native ES6 promises

More examples:

Here.

Keywords

FAQs

Package last updated on 12 Nov 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc