[Pkg-javascript-commits] [node-keygrip] 27/68: better spacing style

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Fri Jun 27 22:13:25 UTC 2014


This is an automated email from the git hooks/post-receive script.

andrewrk-guest pushed a commit to branch master
in repository node-keygrip.

commit 0b8af3a6afda6273e4e99ae4bbc0f1ee807c7dde
Author: Jed Schmidt <tr at nslator.jp>
Date:   Mon Jul 9 23:34:12 2012 +0900

    better spacing style
---
 index.js   | 61 ++++++++++++++++++++++++++++++-------------------------------
 install.js | 10 +++++-----
 2 files changed, 35 insertions(+), 36 deletions(-)

diff --git a/index.js b/index.js
index 8b0e2e5..ec82d09 100644
--- a/index.js
+++ b/index.js
@@ -1,48 +1,47 @@
-crypto = require( "crypto" )
-path = require( "path" )
-fs = require( "fs" )
-
-keysPath = path.join( __dirname, "defaultKeys.json" )
-
-defaults = fs.existsSync( keysPath )
-  ? JSON.parse( fs.readFileSync( keysPath ) )
-  : undefined
-
-function Keygrip( keys ) {
-  if ( !( this instanceof Keygrip ) ) return new Keygrip( keys )
-  
-  if ( !keys || !( 0 in keys ) ) {
-    if ( keys = defaults ) console.warn( "No keys specified, using defaults instead." )
-    
+var crypto = require("crypto")
+  , path   = require("path")
+  , fs     = require("fs")
+
+  , keysPath = path.join(__dirname, "defaultKeys.json")
+  , defaults = fs.existsSync(keysPath)
+      ? JSON.parse(fs.readFileSync(keysPath))
+      : undefined
+
+function Keygrip(keys) {
+  if (!(this instanceof Keygrip)) return new Keygrip(keys)
+
+  if (!keys || !(0 in keys)) {
+    if (keys = defaults) console.warn("No keys specified, using defaults instead.")
+
     else throw "Keys must be provided or default keys must exist."
   }
-  
-  function sign( data, key ) {
+
+  function sign(data, key) {
     return crypto
-      .createHmac( "sha1", key )
-      .update( data ).digest( "base64" )
-      .replace( /\/|\+|=/g, function( x ) {
-        return ({ "/": "_", "+": "-", "=": "" })[ x ]  
+      .createHmac("sha1", key)
+      .update(data).digest("base64")
+      .replace(/\/|\+|=/g, function(x) {
+        return ({ "/": "_", "+": "-", "=": "" })[x]
       })
   }
 
-  this.sign = function( data ){ return sign( data, keys[ 0 ] ) }
+  this.sign = function(data){ return sign(data, keys[0]) }
 
-  this.verify = function( data, digest ) {
-    return this.index( data, digest ) > -1
+  this.verify = function(data, digest) {
+    return this.index(data, digest) > -1
   }
 
-  this.index = function( data, digest ) {
-    for ( var i = 0, l = keys.length; i < l; i++ ) {
-      if ( digest === sign( data, keys[ i ] ) ) return i
+  this.index = function(data, digest) {
+    for (var i = 0, l = keys.length; i < l; i++) {
+      if (digest === sign(data, keys[i])) return i
     }
-    
+
     return -1
   }
 }
 
 Keygrip.sign = Keygrip.verify = Keygrip.index = function() {
-  throw "Usage: require( 'keygrip' )( <array-of-keys> )"
+  throw "Usage: require('keygrip')(<array-of-keys>)"
 }
 
-module.exports = Keygrip
\ No newline at end of file
+module.exports = Keygrip
diff --git a/install.js b/install.js
index 346dc9e..9afac64 100644
--- a/install.js
+++ b/install.js
@@ -1,7 +1,7 @@
-require( "fs" ).writeFileSync( "./defaultKeys.json",
+require("fs").writeFileSync("./defaultKeys.json",
   JSON.stringify([
-    Array( 33 ).join( "x" ).replace( /x/g, function() {
-      return ( Math.random()*16|0 ).toString(16)
+    Array(33).join("x").replace(/x/g, function() {
+      return (Math.random() * 16|0).toString(16)
     })
-  ])
-)
\ No newline at end of file
+ ])
+)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-keygrip.git



More information about the Pkg-javascript-commits mailing list