初始化

This commit is contained in:
yziiy
2025-08-11 11:06:07 +08:00
parent 083bc37c00
commit 5607d11395
19772 changed files with 3108723 additions and 18 deletions

21
uni_modules/UniDevTools/node_modules/any-base/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Kamil Harasimowicz and contributors
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.

View File

@@ -0,0 +1,55 @@
# README #
The library allows you to convert any large numbers in any number base to another number base. The base is determined by specifying the alphabet. So is full freedom
[![NPM](https://nodei.co/npm/any-base.png?downloads=true&stars=true)](https://nodei.co/npm/any-base/)
## Installation ##
```
npm install any-base --save
```
## API ##
### AnyBase() ###
```
converterFunction = anyBase(sourceAlphabet, destinationAlphabet);
```
#### Parameters ####
* {String} __sourceAlphabet__ digits from smallest to the largest
* {String} __destinationAlphabet__ digits from smallest to the largest
#### Return Values ####
Returns __function__ that converts the number of source base to the destination
### Convert() ###
```
converterFunction(number)
```
#### Parameters ####
* {String} __number__ number of source base
#### Return Values ####
Returns number of destonation base
## Example ##
```js
var anyBase = require('any-base'),
dec2hex = anyBase(anyBase.DEC, anyBase.HEX),
shortId = anyBase(anyBase.DEC, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+!@#$^'),
longId = anyBase('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+!@#$^', anyBase.DEC);
dec2hex('123456'); // return: '1E240'
shortId('1234567890'); // return: 'PtmIa'
longId('PtmIa'); // return: '1234567890'
```

View File

@@ -0,0 +1,94 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.AnyBase = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
/**
* Converter
*
* @param {string} srcAlphabet
* @param {string} dstAlphabet
* @constructor
*/
function Converter(srcAlphabet, dstAlphabet) {
if (!srcAlphabet || !dstAlphabet || !srcAlphabet.length || !dstAlphabet.length) {
throw new Error('Bad alphabet');
}
this.srcAlphabet = srcAlphabet;
this.dstAlphabet = dstAlphabet;
}
/**
* Convert number from source alphabet to destonation alphabet
*
* @param {string} number - number represent as a string
*
* @returns {string}
*/
Converter.prototype.convert = function(number) {
var i, divide, newlen,
numberMap = {},
fromBase = this.srcAlphabet.length,
toBase = this.dstAlphabet.length,
length = number.length,
result = '';
if (this.srcAlphabet === this.dstAlphabet) {
return number;
}
for (i = 0; i < length; i++) {
numberMap[i] = this.srcAlphabet.indexOf(number[i]);
}
do {
divide = 0;
newlen = 0;
for (i = 0; i < length; i++) {
divide = divide * fromBase + numberMap[i];
if (divide >= toBase) {
numberMap[newlen++] = parseInt(divide / toBase, 10);
divide = divide % toBase;
} else if (newlen > 0) {
numberMap[newlen++] = 0;
}
}
length = newlen;
result = this.dstAlphabet[divide] + result;
} while (newlen != 0);
return result;
}
module.exports = Converter;
},{}],2:[function(require,module,exports){
var Converter = require('./src/converter');
/**
* Function get source and destination alphabet and return convert function
*
* @param {string} srcAlphabet
* @param {string} dstAlphabet
*
* @returns {function(number)}
*/
function anyBase(srcAlphabet, dstAlphabet) {
var converter = new Converter(srcAlphabet, dstAlphabet);
/**
* Convert function
*
* @param {string} number
*
* @return {string} number
*/
return function (number) {
return converter.convert(number);
}
};
anyBase.BIN = '01';
anyBase.OCT = '01234567';
anyBase.DEC = '0123456789';
anyBase.HEX = '0123456789abcdef';
module.exports = anyBase;
},{"./src/converter":1}]},{},[2])(2)
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJzcmMvY29udmVydGVyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0FDQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQU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Gl2aWRlID0gZGl2aWRlICogZnJvbUJhc2UgKyBudW1iZXJNYXBbaV07XG4gICAgICAgICAgICBpZiAoZGl2aWRlID49IHRvQmFzZSkge1xuICAgICAgICAgICAgICAgIG51bWJlck1hcFtuZXdsZW4rK10gPSBwYXJzZUludChkaXZpZGUgLyB0b0Jhc2UsIDEwKTtcbiAgICAgICAgICAgICAgICBkaXZpZGUgPSBkaXZpZGUgJSB0b0Jhc2U7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKG5ld2xlbiA+IDApIHtcbiAgICAgICAgICAgICAgICBudW1iZXJNYXBbbmV3bGVuKytdID0gMDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBsZW5ndGggPSBuZXdsZW47XG4gICAgICAgIHJlc3VsdCA9IHRoaXMuZHN0QWxwaGFiZXRbZGl2aWRlXSArIHJlc3VsdDtcbiAgICB9IHdoaWxlIChuZXdsZW4gIT0gMCk7XG5cbiAgICByZXR1cm4gcmVzdWx0O1xufVxuXG5tb2R1bGUuZXhwb3J0cyA9IENvbnZlcnRlcjsiXX0=

View File

@@ -0,0 +1 @@
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.AnyBase=e()}}(function(){return function e(t,n,r){function o(f,s){if(!n[f]){if(!t[f]){var u="function"==typeof require&&require;if(!s&&u)return u(f,!0);if(i)return i(f,!0);var c=new Error("Cannot find module '"+f+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[f]={exports:{}};t[f][0].call(l.exports,function(e){var n=t[f][1][e];return o(n||e)},l,l.exports,e,t,n,r)}return n[f].exports}for(var i="function"==typeof require&&require,f=0;f<r.length;f++)o(r[f]);return o}({1:[function(e,t,n){"use strict";function r(e,t){if(!(e&&t&&e.length&&t.length))throw new Error("Bad alphabet");this.srcAlphabet=e,this.dstAlphabet=t}r.prototype.convert=function(e){var t,n,r,o={},i=this.srcAlphabet.length,f=this.dstAlphabet.length,s=e.length,u="string"==typeof e?"":[];if(this.srcAlphabet===this.dstAlphabet)return e;for(t=0;t<s;t++)o[t]=this.srcAlphabet.indexOf(e[t]);do{for(n=0,r=0,t=0;t<s;t++)n=n*i+o[t],n>=f?(o[r++]=parseInt(n/f,10),n%=f):r>0&&(o[r++]=0);s=r,u=this.dstAlphabet.slice(n,n+1).concat(u)}while(0!==r);return u},t.exports=r},{}],2:[function(e,t,n){function r(e,t){var n=new o(e,t);return function(e){return n.convert(e)}}var o=e("./src/converter");r.BIN="01",r.OCT="01234567",r.DEC="0123456789",r.HEX="0123456789abcdef",t.exports=r},{"./src/converter":1}]},{},[2])(2)});

30
uni_modules/UniDevTools/node_modules/any-base/index.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
var Converter = require('./src/converter');
/**
* Function get source and destination alphabet and return convert function
*
* @param {string|Array} srcAlphabet
* @param {string|Array} dstAlphabet
*
* @returns {function(number|Array)}
*/
function anyBase(srcAlphabet, dstAlphabet) {
var converter = new Converter(srcAlphabet, dstAlphabet);
/**
* Convert function
*
* @param {string|Array} number
*
* @return {string|Array} number
*/
return function (number) {
return converter.convert(number);
}
};
anyBase.BIN = '01';
anyBase.OCT = '01234567';
anyBase.DEC = '0123456789';
anyBase.HEX = '0123456789abcdef';
module.exports = anyBase;

View File

@@ -0,0 +1,40 @@
{
"name": "any-base",
"version": "1.1.0",
"description": "Converter from any base to other any base",
"main": "index.js",
"scripts": {
"start": "./node_modules/.bin/watchify . -s AnyBase -o dist/any-base.js -v -d",
"build": "./node_modules/.bin/browserify . -s AnyBase | ./node_modules/.bin/uglifyjs -cm > dist/any-base.min.js",
"test": "node tests/test.js"
},
"keywords": [
"number",
"convert",
"base",
"alphabet",
"short number",
"long numbers",
"dec",
"hex",
"bin",
"oct",
"any"
],
"repository": {
"type": "git",
"url": "https://github.com/HarasimowiczKamil/any-base.git"
},
"author": {
"name": "Kamil Harasimowicz",
"email": "mifczu@gmail.com"
},
"license": "MIT",
"dependencies": {},
"devDependencies": {
"browserify": "^13.1.1",
"punycode": "^2.1.0",
"uglify-js": "^2.7.4",
"watchify": "^3.7.0"
}
}

View File

@@ -0,0 +1,80 @@
'use strict';
/**
* Converter
*
* @param {string|Array} srcAlphabet
* @param {string|Array} dstAlphabet
* @constructor
*/
function Converter(srcAlphabet, dstAlphabet) {
if (!srcAlphabet || !dstAlphabet || !srcAlphabet.length || !dstAlphabet.length) {
throw new Error('Bad alphabet');
}
this.srcAlphabet = srcAlphabet;
this.dstAlphabet = dstAlphabet;
}
/**
* Convert number from source alphabet to destination alphabet
*
* @param {string|Array} number - number represented as a string or array of points
*
* @returns {string|Array}
*/
Converter.prototype.convert = function(number) {
var i, divide, newlen,
numberMap = {},
fromBase = this.srcAlphabet.length,
toBase = this.dstAlphabet.length,
length = number.length,
result = typeof number === 'string' ? '' : [];
if (!this.isValid(number)) {
throw new Error('Number "' + number + '" contains of non-alphabetic digits (' + this.srcAlphabet + ')');
}
if (this.srcAlphabet === this.dstAlphabet) {
return number;
}
for (i = 0; i < length; i++) {
numberMap[i] = this.srcAlphabet.indexOf(number[i]);
}
do {
divide = 0;
newlen = 0;
for (i = 0; i < length; i++) {
divide = divide * fromBase + numberMap[i];
if (divide >= toBase) {
numberMap[newlen++] = parseInt(divide / toBase, 10);
divide = divide % toBase;
} else if (newlen > 0) {
numberMap[newlen++] = 0;
}
}
length = newlen;
result = this.dstAlphabet.slice(divide, divide + 1).concat(result);
} while (newlen !== 0);
return result;
};
/**
* Valid number with source alphabet
*
* @param {number} number
*
* @returns {boolean}
*/
Converter.prototype.isValid = function(number) {
var i = 0;
for (; i < number.length; ++i) {
if (this.srcAlphabet.indexOf(number[i]) === -1) {
return false;
}
}
return true;
};
module.exports = Converter;