New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-bigpipe

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-bigpipe - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

demo/DemoController.js

2

back-end/Bigpipe.es5.js

@@ -13,3 +13,3 @@ 'use strict';

* FOR BIGPIPE
* 模块化bigpipe, 可以url 访问,也可以api调用
* Modular bigpipe API
*/

@@ -16,0 +16,0 @@

/**
* FOR BIGPIPE
* 模块化bigpipe, 可以url 访问,也可以api调用
* Modular bigpipe API
*/

@@ -5,0 +5,0 @@

{
"name": "node-bigpipe",
"version": "1.0.8",
"description": "bigpipe for nodejs,express,sails,thinkjs,node-web,modular bigpipe for node",
"version": "1.0.9",
"description": "bigpipe for nodejs,express,sails,thinkjs,node-web,modular bigpipe for Node",
"main": "back-end/Bigpipe.es5.js",

@@ -14,3 +14,3 @@ "engines": {

"type": "git",
"url": "git+https://github.com/xunuoi/sails-bigpipe.git"
"url": "git+https://github.com/xunuoi/node-bigpipe.git"
},

@@ -30,5 +30,5 @@ "keywords": [

"bugs": {
"url": "https://github.com/xunuoi/sails-bigpipe/issues"
"url": "https://github.com/xunuoi/node-bigpipe/issues"
},
"homepage": "https://github.com/xunuoi/sails-bigpipe#readme"
"homepage": "https://github.com/xunuoi/node-bigpipe#readme"
}

@@ -1,15 +0,17 @@

# node-bigpipe
# [![node-bigpipe](https://raw.githubusercontent.com/xunuoi/node-bigpipe/master/meta/logo.png)](https://github.com/xunuoi/node-bigpipe) node-bigpipe
[![NPM version](https://img.shields.io/npm/v/node-bigpipe.svg?style=flat-square)](http://badge.fury.io/js/node-bigpipe)<img src="https://raw.githubusercontent.com/xunuoi/node-bigpipe/master/meta/build.png?style=flat-square" width="90" alt="Build status" />
### Introduction
- Bigpie module for nodejs, web frameworks like Express, Sails, ThinkJS
- ONLY 3 Simple API: `start`, `pipe`, `end`
- Based on `Promise`, easy to write
- Only 3 Simple API: `start`, `pipe`, `end`, very light and transparent
- Based on `Promise`, easy to use and control
### Install
- [Copy Files into Your Project] OR [Use npm: `npm install node-bigpipe --save-dev`]
- Backend in ES6: `import {Bigpipe} from 'node-bigpipe'` or `import {Bigpipe} from './back-end/Bigpipe'`
- Backend in ES5: `var Bigpipe = require('node-bigpipe').Bigpipe` or `var Bigpipe = require('./back-end/Bigpipe.es5').Bigpipe`
- Front-End: use the `jQuery` and `mo.bigpipe.es5.js` files in your html
- Also you can wrap the front-end js by yourself, remember matching the `Bigpipe` API of Backend
- Backend side: [npm: `npm install node-bigpipe --save-dev`]. Or [Copy Files into your project directly]
- Frontend side: Involve the `jQuery` and `bro.bigpipe.js` scripts into html. Or `require('node-bigpipe/static/bro.bigpipe')` by `webpack` or `browserify`.
- **You can write the Frontend js code by yourself, make sure to match the `Bigpipe` API of Backend.**

@@ -19,3 +21,6 @@

* In Backend you should create a pipe block and return a promise
In Backend, you should use `node-bigpipe` to create a bigpipe for response.
In Frontend, you can use `bro.bigpipe.js`, or use your own js code to call the `bigpipe` from Backend.
Step:
* require the `node-bigpipe` module by `var Bigpipe = require('node-bigpipe').Bigpipe`

@@ -66,3 +71,3 @@ * Create an Bigpipe by `var bigpipe = new Bigpipe('pipeName', req, res)`

}
//
// Here the `tag` event names will subscribed by Frontend js code.
bp.fire('tag', pipeData)

@@ -76,3 +81,3 @@ resolve()

- In view controller, start the pipe
- In Backend controller, start the pipe

@@ -107,15 +112,19 @@ ```Javascript

// this method will automatically export a object `karatBP` in window, and the `_bigpipe_id` shoud match the definition in backend
// This method will automatically export a object `karatBP` in window. And the `_bigpipe_id` shoud match the definition in backend
new Bigpipe('karatBP')
// you can also get the `_bigpipe_id` from data which has been mixed by Bigpipe:
// You can also use the `_bigpipe_id` parameter from backend by defaultl below:
// new Bigpipe('{{_bigpipe_id}}')
</script>
```
- Full backend code TestController.js:
### Full Demo Code
- Full Backend demo code in `demo/DemoController.js`:
```Javascript
// this is a bigpipe, you should return a promise in the bigpipe-function.
function tagPipe(bp){

@@ -127,3 +136,3 @@ return new Promise((resolve, reject)=>{

// simulate the asynchronous response
// simulate the asynchronous response, it may be replaced by DB/IO/NETWORK and other async operations.
setTimeout(()=>{

@@ -138,3 +147,3 @@ let html = '<div><span>TagA</span><span>TagB</span><span>TagC</span><span>TagD</span></div>'

}
// here the `tag` match the event in front end.
// here the `tag` match the event in frontend. You can use the bigpipe by `on('tag')` in Frontend js code.
bp.fire('tag', pipeData)

@@ -147,2 +156,3 @@ resolve()

// another bigpipe
function articlePipe(bp){

@@ -164,2 +174,3 @@ return new Promise((resolve, reject)=>{

// here the `index` fn should be bound in router so it can be views by url
// the `view/home` is the basic html template, you can define some container div/elements in this html.
export default {

@@ -175,3 +186,3 @@

// other ...
// other pipe...
])

@@ -183,12 +194,15 @@ .end()

- Full front end code
- Full Frontend demo code
```HTML
<!-- If you want, you can write your own Frontend js to replace `jquery` and `bro.bigpipe` here. -->
<script type="text/javascript" src="/static/jquery.min.js"></script>
<script type="text/javascript" src="/static/mo.bigpipe.es5.js"></script>
<script type="text/javascript" src="/static/bro.bigpipe.js"></script>
<!-- Here will use the bigpipe object transported from Backend -->
<script type="text/javascript">
// The `karatBP` is the bigpipe-id, it should match the Backend definition. Or you can use '{{_bigpipe_id}}' directly.
new Bigpipe('karatBP')
// subscribe the events which match the backend API `fire`, like fire('tag', data)
// You can subscribe the events which match the backend API `fire`, like fire('tag', data), then you can `on('tag')` in FE js.
karatBP.on('tag')

@@ -200,2 +214,3 @@ .then(function (data) {

})
</script>

@@ -239,12 +254,6 @@ ```

### ES6 Version
- The default used file is `back-end/Bigpipe.es5.js` which is ES5
### More
- If you want use the ES6 version ,just modify the `package.json` in node-bigpipe dir, and modify the `"main": "back-end/Bigpipe.es5.js",` into `"main": "back-end/Bigpipe.js",`
Please check the demo code in `demo` folder in the repository. And the Frontend js code is in `static` folder.
### Readme
View full demo code in this github repo files.
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