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

tingyun-browser-util

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tingyun-browser-util - npm Package Compare versions

Comparing version 1.0.4 to 1.0.19

pub-sub/index.js

182

index.js

@@ -29,3 +29,3 @@ import window from 'window';

var _listener = function() {
off(target, event, listener);
off(target, event, _listener);
return listener.apply(this, arguments);

@@ -54,13 +54,15 @@ }

var length, i = 0;
if (isArrayLike(obj)) {
length = obj.length;
for (; i < length; i++) {
if (callback.call(obj[i], obj[i], i) === false) {
break;
if (obj) {
if (isArrayLike(obj)) {
length = obj.length;
for (; i < length; i++) {
if (callback.call(obj[i], obj[i], i) === false) {
break;
}
}
}
} else {
for (i in obj) {
if (callback.call(obj[i], obj[i], i) === false) {
break;
} else {
for (i in obj) {
if (callback.call(obj[i], obj[i], i) === false) {
break;
}
}

@@ -73,9 +75,9 @@ }

export function onlyOnce(fn) {
var called = false;
return function() {
if (called) {
if (fn === null) {
return;
}
called = true;
fn.apply(this, arguments);
var func = fn;
fn = null;
func.apply(this, arguments);
}

@@ -89,15 +91,80 @@ }

//ie6-ie8
export function isIE() {
return !+[1, ];
var isIE = new Function('return!+[1,]');
export {
isIE as isIE
};
var slice = [].slice;
export {
slice as slice
};
export function extend(obj) {
var length = arguments.length;
if (length < 2 || !obj) {
return obj;
}
var targets = slice.call(arguments, 1);
each(targets, function(source) {
each(source, function(val, key) {
obj[key] = val;
});
});
return obj;
}
export function extend() {}
var parse;
if (window.JSON && window.JSON.parse) {
parse = window.JSON.parse;
var stringify;
var JSON = window.JSON;
var QUOTE;
var QUOTE_REG;
var NEWLINE_REG;
if (JSON && JSON.parse && JSON.stringify) {
parse = function(data) {
return JSON.parse(data);
};
stringify = function(data) {
return JSON.stringify(data);
};
} else {
QUOTE = '\"';
QUOTE_REG = /([\"\\])/g;
NEWLINE_REG = /\n/g;
parse = function(arg) {
return (new Function("return " + arg))();
};
stringify = function(data) {
switch (typeof value) {
case 'object':
if (!value) {
return 'null';
}
if (value instanceof Array) {
each(value, function(val, index) {
value[index] = stringify(val);
});
return '[' + value.concat(',') + ']';
}
var result = '';
each(value, function(val, key) {
if (!isFunction(val)) {
result += (key + ':' + stringify(val) + ',');
}
})
if (result) {
result = result.substr(0, result.length - 1);
}
return '{' + result + '}';
case 'string':
return QUOTE + value.replace(QUOTE_REG, '\\$1').replace(NEWLINE_REG, '\\n') + QUOTE;
case 'number':
return value.toString();
case 'boolean':
return value ? 'true' : 'false';
case 'function':
return stringify(value.toString());
case 'undefined':
default:
return '\"undefined\"';
}
};
}

@@ -112,5 +179,5 @@

export function isFunction(func) {
return typeof func === 'function';
}
export {
stringify as stringify
};

@@ -129,2 +196,3 @@ function isType(type) {

export var isFunction = isType('Function');
export var isObject = isType('Object');

@@ -147,3 +215,3 @@ export function size(data) {

}
return 0
return 0;
}

@@ -156,6 +224,6 @@

url = currentProtocal + '//';
url += (host + path + '/');
url += (host + path);
if (params) {
url += '?'
each(params, function (value, key) {
each(params, function(value, key) {
var pair = [enc(key), '=', enc(value), '&'];

@@ -170,3 +238,61 @@ url += pair.join('');

export function noop() {
export function noop() {}
export function applyFunction(fn, args) {
return Function.prototype.apply.apply(fn, args);
}
export function bind(fn, context) {
return function() {
fn.apply(context, arguments);
}
}
export function startsWith(target, searchString, position) {
if (!target) {
return false;
}
position = position || 0;
return target.indexOf(searchString, position);
}
var trim = String.prototype.trim ? function(text) {
return text == null ? '' : text.trim();
} : function(text) {
return text == null ? '' : text.toString().replace(/^\s+/, '').replace(/\s+$/, '');
};
export {
trim as trim
};
export function wrap(target, name, wrapper) {
if (!target) {
return;
}
if (!wrapper) {
return;
}
if (!isFunction(wrapper)) {
return;
}
var original = target[name];
if (original && original._wrapped) {
return;
}
var wrapped = wrapper(original);
wrapped._wrapped = true;
target[name] = wrapped;
return wrapped;
}
function part() {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
}
export function guid() {
return part() + '-' + part() + part();
}
export function nextTick(fn) {
return setTimeout(fn, 0);
}

2

package.json
{
"name": "tingyun-browser-util",
"version": "1.0.4",
"version": "1.0.19",
"description": "utils for tingyun browser agent ",

@@ -5,0 +5,0 @@ "main": "index.js",

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