New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

xapp-page

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xapp-page - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

4

component.js

@@ -71,3 +71,3 @@ import Store from './store';

if (dataKey.indexOf(key) === -1) return;
if (this.data[key] == this._data[key]) return;
if (utils.eq(this.data[key], this._data[key])) return;
let f = watch[key];

@@ -87,3 +87,3 @@ typeof f === 'function' && f.call(this, this.data[key], this._data[key]);

this.setStateAsync = function(data) {
this.setDataAsync = this.setStateAsync = function(data) {
return new Promise(resolve => {

@@ -90,0 +90,0 @@ this.setData(data, value => {

@@ -12,3 +12,3 @@ export default {

// xapp版本号
XAPP_VERSION: '1.0.1',
XAPP_VERSION: '1.0.2',
}

@@ -7,2 +7,3 @@ /**

import './page';
import utils from './utils';
import Store from './store';

@@ -22,3 +23,3 @@ import config from './config';

if (wxVersion < MIN_VERSION) {
if (!utils.compareVersion(wxVersion, MIN_VERSION)) {
console.error('xapp运行异常,可能出现未知错误,请升级基础库')

@@ -25,0 +26,0 @@ }

{
"name": "xapp-page",
"version": "1.0.1",
"version": "1.0.2",
"description": "xapp-page",

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

@@ -6,5 +6,5 @@ import utils from './utils';

import Store from './store';
import config from './config';
const $store = Store.getInstance({});
import config from './config';
const $store = Store.getInstance({});
const originPage = Page;

@@ -31,3 +31,3 @@

*/
setting.setStateAsync = function(data) {
setting.setDataAsync = setting.setStateAsync = function(data) {
return new Promise(resolve => {

@@ -118,3 +118,4 @@ this.setData(data, value => {

// 低版本兼容,在基础库2.2.3以下时,官方Component组件不支持show生命周期
config.WX_VERSION < config.MIN_VERSION_SUPPORT_SHOW && $store.updateComponentData(this.__wxWebviewId__);
utils.compareVersion(config.MIN_VERSION_SUPPORT_SHOW, config.WX_VERSION) &&
$store.updateComponentData(this.__wxWebviewId__);
onShow && onShow.call(this, options);

@@ -189,3 +190,3 @@ }

if (dataKey.indexOf(key) === -1) return;
if (this.data[key] == this._data[key]) return;
if (utils.eq(this.data[key], this._data[key])) return;
let f = watch[key];

@@ -192,0 +193,0 @@ typeof f === 'function' && f.call(this, this.data[key], this._data[key]);

@@ -1,1 +0,11 @@

#xapp
# 按钮
#### v1.0.1
* 修改所有setData -> setState
#### 基本调用
```js
```

@@ -73,4 +73,6 @@ import utils from './utils';

link.forEach(key => {
if (utils.eq(o.data[key], this.store[key])) return;
newData[key] = this.store[key];
});
if (Object.keys(newData).length === 0) return;
o.hasOwnProperty('setState') ? o.setState(newData) : o.setData(newData);

@@ -77,0 +79,0 @@ }

@@ -118,2 +118,5 @@ import regeneratorRuntime from './runtime';

mixin.hasOwnProperty('default') && (mixin = mixin.default);
if (utils.isObject(mixin)) {
return setting = utils.assign(mixin, setting);
}
if (!utils.isFunction(mixin)) throw new Error('mixin 类型必须是函数!');

@@ -131,2 +134,106 @@ mixin = mixin();

var toString = Object.prototype.toString;
function isFunction(obj) {
return toString.call(obj) === '[object Function]'
}
utils.eq = function(a, b, aStack, bStack) {
// === 结果为 true 的区别出 +0 和 -0
if (a === b) return a !== 0 || 1 / a === 1 / b;
// typeof null 的结果为 object ,这里做判断,是为了让有 null 的情况尽早退出函数
if (a == null || b == null) return false;
// 判断 NaN
if (a !== a) return b !== b;
// 判断参数 a 类型,如果是基本类型,在这里可以直接返回 false
var type = typeof a;
if (type !== 'function' && type !== 'object' && typeof b != 'object') return false;
// 更复杂的对象使用 deepEq 函数进行深度比较
return deepEq(a, b, aStack, bStack);
};
function deepEq(a, b, aStack, bStack) {
// a 和 b 的内部属性 [[class]] 相同时 返回 true
var className = toString.call(a);
if (className !== toString.call(b)) return false;
switch (className) {
case '[object RegExp]':
case '[object String]':
return '' + a === '' + b;
case '[object Number]':
if (+a !== +a) return +b !== +b;
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
case '[object Date]':
case '[object Boolean]':
return +a === +b;
}
var areArrays = className === '[object Array]';
// 不是数组
if (!areArrays) {
// 过滤掉两个函数的情况
if (typeof a != 'object' || typeof b != 'object') return false;
var aCtor = a.constructor,
bCtor = b.constructor;
// aCtor 和 bCtor 必须都存在并且都不是 Object 构造函数的情况下,aCtor 不等于 bCtor, 那这两个对象就真的不相等啦
if (aCtor == bCtor &&
!(isFunction(aCtor) && aCtor instanceof aCtor && isFunction(bCtor) && bCtor instanceof bCtor) &&
('constructor' in a && 'constructor' in b)) {
return false;
}
}
aStack = aStack || [];
bStack = bStack || [];
var length = aStack.length;
// 检查是否有循环引用的部分
while (length--) {
if (aStack[length] === a) {
return bStack[length] === b;
}
}
aStack.push(a);
bStack.push(b);
// 数组判断
if (areArrays) {
length = a.length;
if (length !== b.length) return false;
while (length--) {
if (!utils.eq(a[length], b[length], aStack, bStack)) return false;
}
}
// 对象判断
else {
var keys = Object.keys(a),
key;
length = keys.length;
if (Object.keys(b).length !== length) return false;
while (length--) {
key = keys[length];
if (!(b.hasOwnProperty(key) && utils.eq(a[key], b[key], aStack, bStack))) return false;
}
}
aStack.pop();
bStack.pop();
return true;
}
/**

@@ -161,2 +268,29 @@ * 深拷贝

utils.compareVersion = function(v1, v2) {
v1 = v1.split('.')
v2 = v2.split('.')
const len = Math.max(v1.length, v2.length)
while (v1.length < len) {
v1.push('0')
}
while (v2.length < len) {
v2.push('0')
}
for (let i = 0; i < len; i++) {
const num1 = parseInt(v1[i])
const num2 = parseInt(v2[i])
if (num1 > num2) {
return true
}
else if (num1 < num2) {
return false
}
}
return true
}
export default { ...utils };
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