Skip to content

Lightweight socket wrapper with promisified question/answer protocol that works over websocket, net, dgram and ipc

License

Notifications You must be signed in to change notification settings

plundell/uniSoc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uniSoc

Lightweight socket wrapper that works over ws, net, dgram and ipc

Installation

Install the npm package: npm -i unisoc.

Usage

In NodeJS:

	const uniSoc=require('unisoc');

In the browser you have 2 options:

a) Include the bundled version directly in the browser as you would any script, you will then be able to access it on window.uniSoc, but you'll get an error until you've loaded the dependency, as so:

<script src="path/to/unisoc/dist/unisoc.min.js" type="text/javascript"></script>
<script type="text/javascript">
  try{
    new window.uniSoc();
  }catch(err){
    console.error(err); // E_DEPENDENCY
  }; 
</script>
<script src="path/to/libbetter/dist/libbetter.js" type="text/javascript"></script>
<script type="text/javascript">
  var unisoc=new window.uniSoc();
</script>

b) Require the package into another script, initialize it with it's dependencies, then bundle that...

var libbetter=require('./path/to/libbetter/export-browser.js');
var unisoc=new (require('xxx-framework')(libbetter));

...and load that in the browser

<script src="path/to/index.js" type="text/javascript">

About

Lightweight socket wrapper with promisified question/answer protocol that works over websocket, net, dgram and ipc

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published