Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

febs

Package Overview
Dependencies
Maintainers
3
Versions
206
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

febs - npm Package Compare versions

Comparing version 0.8.5 to 0.8.6

browser/common/utils.bigint.js

83

browser/common/utils.js

@@ -10,4 +10,2 @@ 'use strict';

var PromiseLib = Promise;
// var BigNumber = require('../third-party/bignumber.min.js');
var BigNumber = require('bignumber.js');

@@ -300,82 +298,1 @@ /**

/**
* @desc: 判断是否是bigint.
*/
exports.bigint_check =
function(v) {
if (Number.isInteger(v))
return true;
if (!v)
return false;
if (typeof v === 'string')
{
if (v.length > 22 || v.length < 1)
return false;
for (var j = 1; j < v.length; j++) {
if (v[j] < '0' || v[j] > '9')
return false;
}
if (v[0] == '-') {
if (v.length < 2 || v[1] < '1' || v[1] > '9')
return false;
} else {
if (v[j] < '1' || v[j] > '9')
return false;
}
return true;
}
else {
return false;
}
}
/**
* @desc: calc bigint
* @return: bigint.
*/
exports.bigint_add =
function(a, b) {if (!(a instanceof BigNumber)) a = new BigNumber(a); return a.plus(b);}
exports.bigint_minus =
function(a, b) {if (!(a instanceof BigNumber)) a = new BigNumber(a); return a.minus(b);}
exports.bigint_dividedBy =
function(a, b) {if (!(a instanceof BigNumber)) a = new BigNumber(a); return a.dividedBy(b);}
exports.bigint_mul =
function(a, b) {if (!(a instanceof BigNumber)) a = new BigNumber(a); return a.times(b);}
/**
* @desc: compare with bigint.
* @return: boolean.
*/
exports.bigint_equal =
function(a, b) {if (!(a instanceof BigNumber)) a = new BigNumber(a); return a.equals(b);}
exports.bigint_more_than =
function(a, b) {if (!(a instanceof BigNumber)) a = new BigNumber(a); return a.greaterThan(b);}
exports.bigint_more_than_e =
function(a, b) {if (!(a instanceof BigNumber)) a = new BigNumber(a); return a.greaterThanOrEqualTo(b);}
exports.bigint_less_than =
function(a, b) {if (!(a instanceof BigNumber)) a = new BigNumber(a); return a.lessThan(b);}
exports.bigint_less_than_e =
function(a, b) {if (!(a instanceof BigNumber)) a = new BigNumber(a); return a.lessThanOrEqualTo(b);}
/**
* @desc: 转换bigint->string.
* @param fixed: 小数位个数, 默认为0.
* @return: string.
*/
exports.bigint_toFixed =
function(a, fixed) { fixed = (fixed||0); if (!(a instanceof BigNumber)) a = new BigNumber(a); return a.toFixed(fixed);}

7

browser/dist/febs/README.md

@@ -30,3 +30,3 @@ febs 库是一些常用的工具的合集;

以下列方式使用
以下列方式使用 (将不同的功能分解到不同的包中)

@@ -38,3 +38,6 @@ > copy directory `node_modules/febs/dist/febs` to client

<link rel="stylesheet" type="text/css" href="path/febs/febs.css" />
<script charset='UTF-8' type="text/javascript" src="path/febs/febs.min.js"></script>
<script charset='UTF-8' type="text/javascript" src="path/febs/febs.js"></script>
<script charset='UTF-8' type="text/javascript" src="path/febs/febs.sha1.js"></script> <!-- febs.crypt.sha1()方法 -->
<script charset='UTF-8' type="text/javascript" src="path/febs/febs.md5.js"></script> <!-- febs.crypt.md5()方法 -->
<script charset='UTF-8' type="text/javascript" src="path/febs/febs.bigint.js"></script> <!-- febs.utils.bigint_xxx()方法 -->

@@ -41,0 +44,0 @@ <script>

@@ -10,4 +10,2 @@ /**

var crypt = require('../common/crypt');
var sha1 = require('sha1');
var md5 = require('md5');

@@ -73,6 +71,2 @@ /**

exports.sha1 = sha1;
exports.md5 = md5;
/**

@@ -79,0 +73,0 @@ * @desc: base64编码.

@@ -6,3 +6,3 @@

// require('babel-polyfill');
require('../third-party/bluebird.min.js');
// require('../third-party/bluebird.min.js');
// require('../third-party/bignumber.min.js');

@@ -53,5 +53,12 @@

febs.utils = require('./utils');
febs.string = require('./string');
febs.crypt = require('./crypt');
febs.utils = require('./utils');
var cryptMd5 = require('./crypt.md5');
febs.crypt = febs.utils.mergeMap(febs.crypt, cryptMd5);
var cryptSha1 = require('./crypt.sha1');
febs.crypt = febs.utils.mergeMap(febs.crypt, cryptSha1);
var utilsBig = require('../common/utils.bigint');
febs.utils = febs.utils.mergeMap(febs.utils, utilsBig);
febs.net = require('./net');

@@ -62,3 +69,12 @@ febs.dom = require('./dom');

window['febs'] = febs;
if (!window['febs'])
window['febs'] = febs;
else {
window['febs'].string = window['febs'].string? febs.utils.mergeMap(window['febs'].string, febs.string) : febs.string;
window['febs'].crypt = window['febs'].crypt? febs.utils.mergeMap(window['febs'].crypt, febs.crypt) : febs.crypt;
window['febs'].utils = window['febs'].utils? febs.utils.mergeMap(window['febs'].utils, febs.utils) : febs.utils;
window['febs'].net = window['febs'].net? febs.utils.mergeMap(window['febs'].net, febs.net) : febs.net;
window['febs'].dom = window['febs'].dom? febs.utils.mergeMap(window['febs'].dom, febs.dom) : febs.dom;
}
if (!window['$'])

@@ -65,0 +81,0 @@ window['$'] = febs['$'];

@@ -89,3 +89,3 @@ /**

// https://github.com/github/fetch
febsnet.fetch_normalizeName = function(name) {
febsnet.normalizeName = function(name) {
if (typeof name !== 'string') {

@@ -100,3 +100,3 @@ name = String(name)

febsnet.fetch_normalizeValue = function(value) {
febsnet.normalizeValue = function(value) {
if (typeof value !== 'string') {

@@ -108,6 +108,6 @@ value = String(value)

febsnet.fetch_Headers = function(headers) {
febsnet.Headers = function(headers) {
this.map = {}
if (headers instanceof febsnet.fetch_Headers) {
if (headers instanceof febsnet.Headers) {
headers.forEach(function(value, name) {

@@ -124,5 +124,5 @@ this.append(name, value)

febsnet.fetch_Headers.prototype.append = function(name, value) {
name = febsnet.fetch_normalizeName(name)
value = febsnet.fetch_normalizeValue(value)
febsnet.Headers.prototype.append = function(name, value) {
name = febsnet.normalizeName(name)
value = febsnet.normalizeValue(value)
var list = this.map[name]

@@ -136,24 +136,24 @@ if (!list) {

febsnet.fetch_Headers.prototype['delete'] = function(name) {
delete this.map[febsnet.fetch_normalizeName(name)]
febsnet.Headers.prototype['delete'] = function(name) {
delete this.map[febsnet.normalizeName(name)]
}
febsnet.fetch_Headers.prototype.get = function(name) {
var values = this.map[febsnet.fetch_normalizeName(name)]
febsnet.Headers.prototype.get = function(name) {
var values = this.map[febsnet.normalizeName(name)]
return values ? values[0] : null
}
febsnet.fetch_Headers.prototype.getAll = function(name) {
return this.map[febsnet.fetch_normalizeName(name)] || []
febsnet.Headers.prototype.getAll = function(name) {
return this.map[febsnet.normalizeName(name)] || []
}
febsnet.fetch_Headers.prototype.has = function(name) {
return this.map.hasOwnProperty(febsnet.fetch_normalizeName(name))
febsnet.Headers.prototype.has = function(name) {
return this.map.hasOwnProperty(febsnet.normalizeName(name))
}
febsnet.fetch_Headers.prototype.set = function(name, value) {
this.map[febsnet.fetch_normalizeName(name)] = [febsnet.fetch_normalizeValue(value)]
febsnet.Headers.prototype.set = function(name, value) {
this.map[febsnet.normalizeName(name)] = [febsnet.normalizeValue(value)]
}
febsnet.fetch_Headers.prototype.forEach = function(callback, thisArg) {
febsnet.Headers.prototype.forEach = function(callback, thisArg) {
Object.getOwnPropertyNames(this.map).forEach(function(name) {

@@ -166,3 +166,3 @@ this.map[name].forEach(function(value) {

febsnet.fetch_consumed = function(body) {
febsnet.consumed = function(body) {
if (body.bodyUsed) {

@@ -174,3 +174,3 @@ return Promise.reject(new TypeError('Already read'))

febsnet.fetch_fileReaderReady = function (reader) {
febsnet.fileReaderReady = function (reader) {
return new Promise(function(resolve, reject) {

@@ -186,15 +186,15 @@ reader.onload = function() {

febsnet.fetch_readBlobAsArrayBuffer = function (blob) {
febsnet.readBlobAsArrayBuffer = function (blob) {
var reader = new FileReader()
reader.readAsArrayBuffer(blob)
return febsnet.fetch_fileReaderReady(reader)
return febsnet.fileReaderReady(reader)
}
febsnet.fetch_readBlobAsText = function (blob) {
febsnet.readBlobAsText = function (blob) {
var reader = new FileReader()
reader.readAsText(blob)
return febsnet.fetch_fileReaderReady(reader)
return febsnet.fileReaderReady(reader)
}
febsnet.fetch_support = {
febsnet.support = {
blob: 'FileReader' in window.self && 'Blob' in window.self && (function() {

@@ -212,3 +212,3 @@ try {

febsnet.fetch_Body = function () {
febsnet.Body = function () {
this.bodyUsed = false

@@ -221,10 +221,10 @@

this._bodyText = body
} else if (febsnet.fetch_support.blob && Blob.prototype.isPrototypeOf(body)) {
} else if (febsnet.support.blob && Blob.prototype.isPrototypeOf(body)) {
this._bodyBlob = body
} else if (febsnet.fetch_support.formData && FormData.prototype.isPrototypeOf(body)) {
} else if (febsnet.support.formData && FormData.prototype.isPrototypeOf(body)) {
this._bodyFormData = body
} else if (!body) {
this._bodyText = ''
} else if (febsnet.fetch_support.arrayBuffer && ArrayBuffer.prototype.isPrototypeOf(body)) {
// Only febsnet.fetch_support ArrayBuffers for POST method.
} else if (febsnet.support.arrayBuffer && ArrayBuffer.prototype.isPrototypeOf(body)) {
// Only febsnet.support ArrayBuffers for POST method.
// Receiving ArrayBuffers happens via Blobs, instead.

@@ -236,5 +236,5 @@ } else {

if (febsnet.fetch_support.blob) {
if (febsnet.support.blob) {
this.blob = function() {
var rejected = febsnet.fetch_consumed(this)
var rejected = febsnet.consumed(this)
if (rejected) {

@@ -254,7 +254,7 @@ return rejected

this.arrayBuffer = function() {
return this.blob().then(febsnet.fetch_readBlobAsArrayBuffer)
return this.blob().then(febsnet.readBlobAsArrayBuffer)
}
this.text = function() {
var rejected = febsnet.fetch_consumed(this)
var rejected = febsnet.consumed(this)
if (rejected) {

@@ -265,3 +265,3 @@ return rejected

if (this._bodyBlob) {
return febsnet.fetch_readBlobAsText(this._bodyBlob)
return febsnet.readBlobAsText(this._bodyBlob)
} else if (this._bodyFormData) {

@@ -275,3 +275,3 @@ throw new Error('could not read FormData body as text')

this.text = function() {
var rejected = febsnet.fetch_consumed(this)
var rejected = febsnet.consumed(this)
return rejected ? rejected : Promise.resolve(this._bodyText)

@@ -281,5 +281,5 @@ }

if (febsnet.fetch_support.formData) {
if (febsnet.support.formData) {
this.formData = function() {
return this.text().then(febsnet.fetch_decode)
return this.text().then(febsnet.decode)
}

@@ -296,3 +296,3 @@ }

// HTTP methods whose capitalization should be normalized
febsnet.fetch_normalizeMethod = function (method) {
febsnet.normalizeMethod = function (method) {
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']

@@ -303,6 +303,6 @@ var upcased = method.toUpperCase()

febsnet.fetch_Request = function (input, options) {
febsnet.Request = function (input, options) {
options = options || {}
var body = options.body
if (febsnet.fetch_Request.prototype.isPrototypeOf(input)) {
if (febsnet.Request.prototype.isPrototypeOf(input)) {
if (input.bodyUsed) {

@@ -314,3 +314,3 @@ throw new TypeError('Already read')

if (!options.headers) {
this.headers = new febsnet.fetch_Headers(input.headers)
this.headers = new febsnet.Headers(input.headers)
}

@@ -329,5 +329,5 @@ this.method = input.method

if (options.headers || !this.headers) {
this.headers = new febsnet.fetch_Headers(options.headers)
this.headers = new febsnet.Headers(options.headers)
}
this.method = febsnet.fetch_normalizeMethod(options.method || this.method || 'GET')
this.method = febsnet.normalizeMethod(options.method || this.method || 'GET')
this.mode = options.mode || this.mode || null

@@ -337,3 +337,3 @@ this.referrer = null

if ((this.method === 'GET' || this.method === 'HEAD') && body) {
throw new TypeError('febsnet.fetch_Body not allowed for GET or HEAD requests')
throw new TypeError('febsnet.Body not allowed for GET or HEAD requests')
}

@@ -343,7 +343,7 @@ this._initBody(body)

febsnet.fetch_Request.prototype.clone = function() {
return new febsnet.fetch_Request(this)
febsnet.Request.prototype.clone = function() {
return new febsnet.Request(this)
}
febsnet.fetch_decode = function (body) {
febsnet.decode = function (body) {
var form = new FormData()

@@ -361,4 +361,4 @@ body.trim().split('&').forEach(function(bytes) {

febsnet.fetch_headers = function (xhr) {
var head = new febsnet.fetch_Headers()
febsnet.headers = function (xhr) {
var head = new febsnet.Headers()
var pairs = xhr.getAllResponseHeaders().trim().split('\n')

@@ -374,5 +374,5 @@ pairs.forEach(function(header) {

febsnet.fetch_Body.call(febsnet.fetch_Request.prototype)
febsnet.Body.call(febsnet.Request.prototype)
febsnet.fetch_Response = function (bodyInit, options) {
febsnet.Response = function (bodyInit, options) {
if (!options) {

@@ -387,13 +387,13 @@ options = {}

this.statusText = options.statusText
this.headers = options.headers instanceof febsnet.fetch_Headers ? options.headers : new febsnet.fetch_Headers(options.headers)
this.headers = options.headers instanceof febsnet.Headers ? options.headers : new febsnet.Headers(options.headers)
this.url = options.url || ''
}
febsnet.fetch_Body.call(febsnet.fetch_Response.prototype)
febsnet.Body.call(febsnet.Response.prototype)
febsnet.fetch_Response.prototype.clone = function() {
return new febsnet.fetch_Response(this._bodyInit, {
febsnet.Response.prototype.clone = function() {
return new febsnet.Response(this._bodyInit, {
status: this.status,
statusText: this.statusText,
headers: new febsnet.fetch_Headers(this.headers),
headers: new febsnet.Headers(this.headers),
url: this.url

@@ -403,4 +403,4 @@ })

febsnet.fetch_Response.error = function() {
var response = new febsnet.fetch_Response(null, {status: 0, statusText: ''})
febsnet.Response.error = function() {
var response = new febsnet.Response(null, {status: 0, statusText: ''})
response.type = 'error'

@@ -412,3 +412,3 @@ return response

febsnet.fetch_Response.redirect = function(url, status) {
febsnet.Response.redirect = function(url, status) {
if (redirectStatuses.indexOf(status) === -1) {

@@ -418,8 +418,8 @@ throw new RangeError('Invalid status code')

return new febsnet.fetch_Response(null, {status: status, headers: {location: url}})
return new febsnet.Response(null, {status: status, headers: {location: url}})
}
window.Headers = febsnet.fetch_Headers;
window.Request = febsnet.fetch_Request;
window.Response = febsnet.fetch_Response;
window.Headers = febsnet.Headers;
window.Request = febsnet.Request;
window.Response = febsnet.Response;

@@ -432,3 +432,3 @@ window.fetch = febsnet.fetch = function(input, init) {

var option;
if (febsnet.fetch_Request.prototype.isPrototypeOf(input) && !init) {
if (febsnet.Request.prototype.isPrototypeOf(input) && !init) {
url = input.url;

@@ -471,4 +471,4 @@ option = input;

// Avoid security warnings on getResponseHeader when not allowed by CORS
if (/^X-febsnet.fetch_Request-URL:/m.test(xhr.getAllResponseHeaders())) {
return xhr.getResponseHeader('X-febsnet.fetch_Request-URL')
if (/^X-febsnet.Request-URL:/m.test(xhr.getAllResponseHeaders())) {
return xhr.getResponseHeader('X-febsnet.Request-URL')
}

@@ -481,7 +481,7 @@

statusText: xhr.statusText,
headers: febsnet.fetch_headers(xhr),
headers: febsnet.headers(xhr),
url: responseURL()
}
var body = 'response' in xhr ? xhr.response : xhr.responseText;
resolve(new febsnet.fetch_Response(body, options))
resolve(new febsnet.Response(body, options))
},

@@ -503,6 +503,6 @@ error: function(xhr, msg) {

var request
if (febsnet.fetch_Request.prototype.isPrototypeOf(input) && !init) {
if (febsnet.Request.prototype.isPrototypeOf(input) && !init) {
request = input
} else {
request = new febsnet.fetch_Request(input, init)
request = new febsnet.Request(input, init)
}

@@ -527,4 +527,4 @@

// Avoid security warnings on getResponseHeader when not allowed by CORS
if (/^X-febsnet.fetch_Request-URL:/m.test(xhr.getAllResponseHeaders())) {
return xhr.getResponseHeader('X-febsnet.fetch_Request-URL')
if (/^X-febsnet.Request-URL:/m.test(xhr.getAllResponseHeaders())) {
return xhr.getResponseHeader('X-febsnet.Request-URL')
}

@@ -544,7 +544,7 @@

// statusText: xhr.statusText,
// headers: febsnet.fetch_headers(xhr),
// headers: febsnet.headers(xhr),
// url: responseURL()
// }
// var body = 'response' in xhr ? xhr.response : xhr.responseText;
// resolve(new febsnet.fetch_Response(body, options))
// resolve(new febsnet.Response(body, options))
// }

@@ -562,7 +562,7 @@

statusText: xhr.statusText,
headers: febsnet.fetch_headers(xhr),
headers: febsnet.headers(xhr),
url: responseURL()
}
var body = 'response' in xhr ? xhr.response : xhr.responseText;
resolve(new febsnet.fetch_Response(body, options))
resolve(new febsnet.Response(body, options))
}

@@ -586,3 +586,3 @@ }

if ('responseType' in xhr && febsnet.fetch_support.blob) {
if ('responseType' in xhr && febsnet.support.blob) {
xhr.responseType = 'blob'

@@ -589,0 +589,0 @@ }

@@ -108,41 +108,2 @@ 'use strict';

/**
* @desc: 判断是否是bigint.
*/
exports.bigint_check = utils.bigint_check;
/**
* @desc: calc bigint
* @return: bigint.
*/
exports.bigint_add = utils.bigint_add;
exports.bigint_minus = utils.bigint_minus;
exports.bigint_dividedBy = utils.bigint_dividedBy;
exports.bigint_mul = utils.bigint_mul;
/**
* @desc: compare with bigint.
* @return: boolean.
*/
exports.bigint_equal = utils.bigint_equal;
exports.bigint_more_than = utils.bigint_more_than;
exports.bigint_more_than_e = utils.bigint_more_than_e;
exports.bigint_less_than = utils.bigint_less_than;
exports.bigint_less_than_e = utils.bigint_less_than_e;
/**
* @desc: 转换bigint->string.
* @param fixed: 小数位个数, 默认为0.
* @return: string.
*/
exports.bigint_toFixed = utils.bigint_toFixed;
/**
* @desc: 判断是否是ie.

@@ -149,0 +110,0 @@ */

@@ -30,3 +30,3 @@ febs 库是一些常用的工具的合集;

以下列方式使用
以下列方式使用 (将不同的功能分解到不同的包中)

@@ -38,3 +38,6 @@ > copy directory `node_modules/febs/dist/febs` to client

<link rel="stylesheet" type="text/css" href="path/febs/febs.css" />
<script charset='UTF-8' type="text/javascript" src="path/febs/febs.min.js"></script>
<script charset='UTF-8' type="text/javascript" src="path/febs/febs.js"></script>
<script charset='UTF-8' type="text/javascript" src="path/febs/febs.sha1.js"></script> <!-- febs.crypt.sha1()方法 -->
<script charset='UTF-8' type="text/javascript" src="path/febs/febs.md5.js"></script> <!-- febs.crypt.md5()方法 -->
<script charset='UTF-8' type="text/javascript" src="path/febs/febs.bigint.js"></script> <!-- febs.utils.bigint_xxx()方法 -->

@@ -41,0 +44,0 @@ <script>

@@ -86,3 +86,3 @@ {

"name": "febs",
"version": "0.8.5"
"version": "0.8.6"
}

@@ -10,2 +10,3 @@ 'use strict';

var utils = require('../browser/common/utils');
var utilsBigint = require('../browser/common/utils.bigint');

@@ -111,3 +112,3 @@ /**

*/
exports.bigint_check = utils.bigint_check;
exports.bigint_check = utilsBigint.bigint_check;

@@ -118,9 +119,9 @@ /**

*/
exports.bigint_add = utils.bigint_add;
exports.bigint_add = utilsBigint.bigint_add;
exports.bigint_minus = utils.bigint_minus;
exports.bigint_minus = utilsBigint.bigint_minus;
exports.bigint_dividedBy = utils.bigint_dividedBy;
exports.bigint_dividedBy = utilsBigint.bigint_dividedBy;
exports.bigint_mul = utils.bigint_mul;
exports.bigint_mul = utilsBigint.bigint_mul;

@@ -131,11 +132,11 @@ /**

*/
exports.bigint_equal = utils.bigint_equal;
exports.bigint_equal = utilsBigint.bigint_equal;
exports.bigint_more_than = utils.bigint_more_than;
exports.bigint_more_than = utilsBigint.bigint_more_than;
exports.bigint_more_than_e = utils.bigint_more_than_e;
exports.bigint_more_than_e = utilsBigint.bigint_more_than_e;
exports.bigint_less_than = utils.bigint_less_than;
exports.bigint_less_than = utilsBigint.bigint_less_than;
exports.bigint_less_than_e = utils.bigint_less_than_e;
exports.bigint_less_than_e = utilsBigint.bigint_less_than_e;

@@ -148,3 +149,3 @@

*/
exports.bigint_toFixed = utils.bigint_toFixed;
exports.bigint_toFixed = utilsBigint.bigint_toFixed;

@@ -151,0 +152,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc