Code Monkey home page Code Monkey logo

node-rfc4122's Introduction

node-rfc4122

npm license npm version npm downloads Build Status

JavaScript implementation of RFC4122: A Universally Unique IDentifier (UUID) URN Namespace

Install

# Latest Stable Release
$ npm install rfc4122

# Latest Commit
$ npm install tflanagan/node-rfc4122

Browserify

This library works out of the box with Browserify.

$ npm install rfc4122
$ npm install -g babel browserify minifier
$ babel rfc4122.js > rfc4122.es5.js
$ browserify rfc4122.es5.js > rfc4122.browserify.js
$ minify rfc4122.browserify.js > rfc4122.browserify.min.js

The use is the same as in Nodejs, but there is no need to require('rfc4122').

<script type="text/javascript" src="rfc4122.browserify.js"></script>
<script type="text/javascript">
	var rfc4122 = new RFC4122();

	...
</script>

Example

const RFC4122 = require('rfc4122');

let rfc4122 = new RFC4122();

rfc4122.v1();
// ebc386d0-4c07-11a5-0ea7-f1d320998c65

rfc4122.v3('6ba7b810-9dad-11d1-80b4-00c04fd430c8', 'string');
// 01ab89a5-ffc7-35b0-89b4-440e5d0949ca

rfc4122.v4();
// b58029b3-4f28-400a-968d-82d6f8def2ab

/* Faster version of V4 */
rfc4122.v4f();
// aad2c1d7-66f1-4b7e-946a-d56ac9da5f48

rfc4122.v5('6ba7b810-9dad-11d1-80b4-00c04fd430c8', 'string');
// fbb6b6b4-f910-5516-b5d9-8967c4835c76

License

Copyright 2014 Tristian Flanagan

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

node-rfc4122's People

Contributors

tflanagan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

blue-j

node-rfc4122's Issues

Generates different v5 uuids than other libraries

var namespace = "c8cc0001-526a-11e6-beb8-9e71128cae77"
var a = "281990";
var b = "211820";

Other libraries:

a: 54218fae-042d-5368-bbb4-275e36d78da5
b: c56ca8b0-8095-5191-b942-141f75fe001c

node-rfc4122:

a: f2ebda30-34ec-56c3-b832-d1c42f7c0d3d
b: 915fd54d-dc75-5096-ac64-0d3e71d4dc2e

same for your example string, other libs: 445b0ebc-d8e2-58b5-a054-8b65ae3e626, node-rfc4122: fbb6b6b4-f910-5516-b5d9-8967c4835c76

(same results within browser as Node)

Tested libs:

(My best guess would be that the conversion to Network byte order and Local byte order is missing?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.