Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

change: format options

  • Loading branch information...
commit f2754e1894df8b52da0daaf629a8934f19a22e2b 1 parent 9021f22
@mah0x211 authored
Showing with 35 additions and 31 deletions.
  1. +8 −11 lib/ossp_uuid.js
  2. +1 −1  package.json
  3. +26 −19 test/test.js
View
19 lib/ossp_uuid.js
@@ -5,18 +5,15 @@
copyright (C) 2011, masatoshi teruya. all rights reserved.
*/
module.exports = require( __dirname + '/../build/default/uuid_binding');
-module.exports.fmt = {
- BIN: 0, /* binary representation (import/export) */
- STR: 1, /* string representation (import/export) */
- SIV: 2, /* single integer value (import/export) */
- TXT: 3 /* textual description (export only) */
-};
-module.exports.V1 = (1 << 0); /* DCE 1.1 v1 UUID */
-module.exports.V3 = (1 << 1); /* DCE 1.1 v3 UUID */
-module.exports.V4 = (1 << 2); /* DCE 1.1 v4 UUID */
-module.exports.V5 = (1 << 3); /* DCE 1.1 v5 UUID */
+module.exports.BIN = 0; /* binary representation (import/export) */
+module.exports.STR = 1; /* string representation (import/export) */
+module.exports.SIV = 2; /* single integer value (import/export) */
+module.exports.TXT = 3; /* textual description (export only) */
+module.exports.V1 = (1 << 0); /* DCE 1.1 v1 UUID */
+module.exports.V3 = (1 << 1); /* DCE 1.1 v3 UUID */
+module.exports.V4 = (1 << 2); /* DCE 1.1 v4 UUID */
+module.exports.V5 = (1 << 3); /* DCE 1.1 v5 UUID */
// module.exports.MC = (1 << 4); /* enforce multi-cast MAC address */
-
module.exports.ns = {
nil: "nil", /* 00000000-0000-0000-0000-000000000000 ("Nil UUID") */
dns: "ns:DNS", /* 6ba7b810-9dad-11d1-80b4-00c04fd430c8 (see RFC 4122) */
View
2  package.json
@@ -7,7 +7,7 @@
],
"description": "OSSP uuid bindings for node.js",
"homepage": "http://github.com/mah0x211/node-ossp-uuid",
- "version" : "0.0.1",
+ "version" : "0.0.3",
"main" : "./lib/ossp_uuid",
"directories" : {
"lib" : "./lib"
View
45 test/test.js
@@ -1,20 +1,27 @@
-var uuid = require('../lib/ossp_uuid');
+var sys = require('sys'),
+ uuid = require('../lib/ossp_uuid');
-console.log( uuid );
-console.log( uuid.version() );
-console.log( 'v1' );
-console.log( uuid.generate( uuid.fmt.STR, uuid.V1 ) );
-console.log( uuid.generate( uuid.fmt.SIV, uuid.V1 ) );
-console.log( uuid.generate( uuid.fmt.TXT, uuid.V1 ) );
-console.log( 'v3' );
-console.log( uuid.generate( uuid.fmt.STR, uuid.V3, uuid.ns.url, 'http://example.com/' ) );
-console.log( uuid.generate( uuid.fmt.SIV, uuid.V3, uuid.ns.url, 'http://example.com/' ) );
-console.log( uuid.generate( uuid.fmt.TXT, uuid.V3, uuid.ns.url, 'http://example.com/' ) );
-console.log( 'v4' );
-console.log( uuid.generate( uuid.fmt.STR, uuid.V4 ) );
-console.log( uuid.generate( uuid.fmt.SIV, uuid.V4 ) );
-console.log( uuid.generate( uuid.fmt.TXT, uuid.V4 ) );
-console.log( 'v5' );
-console.log( uuid.generate( uuid.fmt.STR, uuid.V5, uuid.ns.url, 'http://example.com/' ) );
-console.log( uuid.generate( uuid.fmt.SIV, uuid.V5, uuid.ns.url, 'http://example.com/' ) );
-console.log( uuid.generate( uuid.fmt.TXT, uuid.V5, uuid.ns.url, 'http://example.com/' ) );
+console.log(
+ "version 1\n" +
+ ' str: ' + uuid.generate( uuid.STR, uuid.V1 ) + "\n" +
+ ' siv: ' + uuid.generate( uuid.SIV, uuid.V1 ) + "\n" +
+ ' bin: ' + sys.inspect( uuid.generate( uuid.BIN, uuid.V1 ) ) + "\n" +
+ " txt: \n" + uuid.generate( uuid.TXT, uuid.V1 ) );
+console.log(
+ "version 3\n" +
+ ' str: ' + uuid.generate( uuid.STR, uuid.V3, uuid.ns.url, 'http://example.com/' ) + "\n" +
+ ' siv: ' + uuid.generate( uuid.SIV, uuid.V3, uuid.ns.url, 'http://example.com/' ) + "\n" +
+ ' bin: ' + sys.inspect( uuid.generate( uuid.BIN, uuid.V3, uuid.ns.url, 'http://example.com/' ) ) + "\n" +
+ ' txt: ' + uuid.generate( uuid.TXT, uuid.V3, uuid.ns.url, 'http://example.com/' ) );
+console.log(
+ "version 4\n" +
+ ' str: ' + uuid.generate( uuid.STR, uuid.V4 ) + "\n" +
+ ' siv: ' + uuid.generate( uuid.SIV, uuid.V4 ) + "\n" +
+ ' bin: ' + sys.inspect( uuid.generate( uuid.BIN, uuid.V4 ) ) + "\n" +
+ " txt: \n" + uuid.generate( uuid.TXT, uuid.V4 ) );
+console.log(
+ "version 5\n" +
+ ' str: ' + uuid.generate( uuid.STR, uuid.V5, uuid.ns.url, 'http://example.com/' ) + "\n" +
+ ' siv: ' + uuid.generate( uuid.SIV, uuid.V5, uuid.ns.url, 'http://example.com/' ) + "\n" +
+ ' bin: ' + sys.inspect( uuid.generate( uuid.BIN, uuid.V5, uuid.ns.url, 'http://example.com/' ) ) + "\n" +
+ " txt: \n" + uuid.generate( uuid.TXT, uuid.V5, uuid.ns.url, 'http://example.com/' ) );
Please sign in to comment.
Something went wrong with that request. Please try again.