Socket
Socket
Sign inDemoInstall

pelo

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pelo - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

compare.js

5

app.js

@@ -1,2 +0,5 @@

module.exports = function (html) {
module.exports = function () {
// Allow `bel` to be swapped in benchmarking
const html = require('bel')
const greeting = 'Hello'

@@ -3,0 +6,0 @@ const name = 'special characters, <, >, &'

29

benchmark.js

@@ -1,21 +0,13 @@

const bel = require('bel')
const stringify = require('.')
const pelo = require('.')
const createApp = require('./app')
const warmup = 100
const iteration = 10000
const strApp = createApp(stringify)
const belApp = createApp(bel)
console.log('# stringify output')
console.log(strApp.render().toString())
console.log('# bel output')
console.log(belApp.render().toString())
console.log(`# benchmark ${iteration} iterations`)
console.time('pelo')
for (let i = 0; i < iteration; i++) {
strApp.render().toString()
const belApp = createApp()
for (let i = 0; i < warmup; i++) {
belApp.render().toString()
}
console.timeEnd('pelo')
console.time('bel')

@@ -26,1 +18,12 @@ for (let i = 0; i < iteration; i++) {

console.timeEnd('bel')
pelo.replace('bel')
const peloApp = createApp()
for (let i = 0; i < warmup; i++) {
peloApp.render().toString()
}
console.time('pelo')
for (let i = 0; i < iteration; i++) {
peloApp.render().toString()
}
console.timeEnd('pelo')

@@ -1,2 +0,1 @@

const bel = require('bel')
const nanomorph = require('nanomorph')

@@ -6,3 +5,3 @@

const app = createApp(bel)
const app = createApp()

@@ -9,0 +8,0 @@ const root = document.getElementById('root')

@@ -0,1 +1,3 @@

const Module = require('module')
function handleValue (value) {

@@ -45,2 +47,14 @@ if (Array.isArray(value)) {

function replace(moduleId) {
const originalRequire = Module.prototype.require
Module.prototype.require = function (id) {
if (id === moduleId) {
return stringify
} else {
return originalRequire.apply(this, arguments)
}
}
}
stringify.replace = replace
module.exports = stringify
{
"name": "pelo",
"version": "0.0.0",
"version": "0.0.1",
"description": "Lightning fast server-side rendering with tagged template literals",
"main": "index.js",
"browser": "bel",
"scripts": {
"start": "npm run build && node server.js",
"test": "node benchmark.js",
"build": "browserify client.js > bundle.js"
"build": "browserify client.js > bundle.js",
"compare": "node compare.js"
},
"dependencies": {
"bel": "^4.6.0"
},
"dependencies": {},
"devDependencies": {
"bel": "^4.6.0",
"browserify": "^14.3.0",

@@ -20,4 +19,9 @@ "nanomorph": "^4.0.4",

},
"homepage": "https://github.com/shuhei/pelo",
"bugs": {
"url": "https://github.com/shuhei/pelo/issues"
},
"repository": "shuhei/pelo",
"author": "Shuhei Kagawa <shuhei.kagawa@gmail.com>",
"license": "ISC"
}

@@ -5,10 +5,28 @@ # pelo (work in progress)

A tiny library that enables lightning fast server-side rendering with [hyperx](https://github.com/substack/hyperx)-like libraries such as `bel`, `yo-yo` and `choo/html`. It replaces the tag function of those libraries and just renders string without creating intermediate objects.
## Installing
```sh
npm install pelo
```
## Usage
**TBD**
`ssr.js`: Call `pelo.replace(moduleId)` before you require any view module, `bel` in this case.
```js
const html = require('pelo')
const pelo = require('pelo')
pelo.replace('bel')
const view = require('./view')
function helloView(name) {
const renderedString = view('pelo').toString()
```
`view.js`: You don't need to change your view files at all. You can use them for client-side rendering and server-side rendering.
```js
const html = require('bel')
module.exports = function helloView(name) {
return html`<p>Hello, ${name}</p>`

@@ -15,0 +33,0 @@ }

const http = require('http')
const fs = require('fs')
const pelo = require('.')
pelo.replace('bel')
const createApp = require('./app')
const html = require('.')
const app = createApp(html)
const app = createApp()

@@ -9,0 +10,0 @@ function layout (content) {

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