首次提交

This commit is contained in:
2026-07-13 12:06:16 +08:00
commit e3c810b1a6
1690 changed files with 228324 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
language: node_js
node_js:
- "10"
- "8"
+6
View File
@@ -0,0 +1,6 @@
Robert Kieffer <robert@broofa.com>
Christoph Tavan <dev@tavan.de>
AJ ONeal <coolaj86@gmail.com>
Vincent Voyer <vincent@zeroload.net>
Roman Shtylman <shtylman@gmail.com>
Brandon Belvin <brandon@sharpcoffee.com>
+8
View File
@@ -0,0 +1,8 @@
# 1.1.0
* Downgraded to ES5-compatible code
* Marked as no longer maintained
# 1.0.0
* Forked from node-uuid in order to recover and expose parse/unparse commands
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2010-2012 Robert Kieffer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+47
View File
@@ -0,0 +1,47 @@
# uuid-parse [![Build Status](https://secure.travis-ci.org/zefferus/uuid-parse.svg?branch=parse)](http://travis-ci.org/zefferus/uuid-parse) #
## NOTE: This module is no longer maintained
Simple, fast parsing and unparsing of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS.
Features:
* Parses and unparses UUIDs to and from Buffer to String
## Quickstart
```shell
npm install uuid-parse
```
```javascript
const uuidParse = require('uuid-parse');
```
## API
### uuidParse.parse(id[, buffer[, offset]])
### uuidParse.unparse(buffer[, offset])
Parse and unparse UUIDs
* `id` - (String) UUID(-like) string
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. Default: A new Buffer is used
* `offset` - (Number) Starting index in `buffer` at which to begin writing. Default: 0
Example parsing and unparsing a UUID string
```javascript
const bytes = uuidParse.parse('797ff043-11eb-11e1-80d6-510998755d10'); // -> <Buffer 79 7f f0 43 11 eb 11 e1 80 d6 51 09 98 75 5d 10>
const string = uuidParse.unparse(bytes); // -> '797ff043-11eb-11e1-80d6-510998755d10'
```
## Testing
```
npm test
```
## Acknowledgments
Please make sure to check out the repository that originated these functions: [node-uuid](https://github.com/kelektiv/node-uuid). These functions were removed from a recent version of that library and I wanted to make sure they were still exposed for the packages who were dependent on them.
+23
View File
@@ -0,0 +1,23 @@
{
"name": "uuid-parse",
"version": "1.1.0",
"description": "RFC4122 UUID parser",
"keywords": [
"uuid",
"parse",
"guid",
"rfc4122"
],
"license": "MIT",
"main": "./uuid-parse.js",
"devDependencies": {
"mocha": "~6.0.0"
},
"scripts": {
"test": "mocha test/test.js"
},
"repository": {
"type": "git",
"url": "https://github.com/zefferus/uuid-parse.git"
}
}
+3
View File
@@ -0,0 +1,3 @@
--ui qunit
--reporter spec
--check-leaks
+12
View File
@@ -0,0 +1,12 @@
var assert = require('assert');
var uuid = require('../');
test('parse/unparse', function() {
var id = '00112233445566778899aabbccddeeff';
assert(uuid.unparse(uuid.parse(id.substr(0,10))) ==
'00112233-4400-0000-0000-000000000000', 'Short parse');
assert(uuid.unparse(uuid.parse('(this is the uuid -> ' + id + id)) ==
'00112233-4455-6677-8899-aabbccddeeff', 'Dirty parse');
});
+48
View File
@@ -0,0 +1,48 @@
'use strict';
// Maps for number <-> hex string conversion
var _byteToHex = [];
var _hexToByte = {};
for (var i = 0; i < 256; i++) {
_byteToHex[i] = (i + 0x100).toString(16).substr(1);
_hexToByte[_byteToHex[i]] = i;
}
// **`parse()` - Parse a UUID into it's component bytes**
function parse(s, buf, offset) {
var i = (buf && offset) || 0;
var ii = 0;
buf = buf || [];
s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) {
if (ii < 16) { // Don't overflow!
buf[i + ii++] = _hexToByte[oct];
}
});
// Zero out remaining bytes if string was short
while (ii < 16) {
buf[i + ii++] = 0;
}
return buf;
}
// **`unparse()` - Convert UUID byte array (ala parse()) into a string**
function unparse(buf, offset) {
var i = offset || 0;
var bth = _byteToHex;
return bth[buf[i++]] + bth[buf[i++]] +
bth[buf[i++]] + bth[buf[i++]] + '-' +
bth[buf[i++]] + bth[buf[i++]] + '-' +
bth[buf[i++]] + bth[buf[i++]] + '-' +
bth[buf[i++]] + bth[buf[i++]] + '-' +
bth[buf[i++]] + bth[buf[i++]] +
bth[buf[i++]] + bth[buf[i++]] +
bth[buf[i++]] + bth[buf[i++]];
}
module.exports = {
parse: parse,
unparse: unparse
};