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

vue-functions

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-functions - npm Package Compare versions

Comparing version 1.0.6 to 2.0.0

475

dist/vue-functions.cjs.js
/*!
* vue-functions v1.0.6
* vue-functions v2.0.0
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)

@@ -10,6 +10,30 @@ * Released under the MIT License.

function isArray(v) {
return Object.prototype.toString.call(v) === '[object Array]';
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
var _marked =
/*#__PURE__*/
regeneratorRuntime.mark(iterateALL); // local store
function isObject(v) {
return Object.prototype.toString.call(v) === '[object Object]';
}
function isFunction(v) {

@@ -24,2 +48,253 @@ return typeof v === 'function';

function arrayRemove(arr, v) {
var index;
var count = 0;
while ((index = arr.indexOf(v)) > -1) {
arr.splice(index, 1);
count++;
}
return count;
}
function iterateALL(val) {
var opt,
i,
info,
_i7,
_Object$keys2,
key,
_info,
_i8,
_info2,
keys,
_i9,
_keys2,
_key2,
_info3,
_args = arguments;
return regeneratorRuntime.wrap(function iterateALL$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
opt = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
if (opt.reverse) {
_context.next = 30;
break;
}
if (!(val.length != null)) {
_context.next = 14;
break;
}
i = 0;
case 4:
if (!(i < val.length)) {
_context.next = 12;
break;
}
info = {
value: val[i],
index: i
};
if (!(!opt.exclude || !opt.exclude(info))) {
_context.next = 9;
break;
}
_context.next = 9;
return info;
case 9:
i++;
_context.next = 4;
break;
case 12:
_context.next = 28;
break;
case 14:
if (!isObject(val)) {
_context.next = 27;
break;
}
_i7 = 0, _Object$keys2 = Object.keys(val);
case 16:
if (!(_i7 < _Object$keys2.length)) {
_context.next = 25;
break;
}
key = _Object$keys2[_i7];
_info = {
value: val[key],
key: key
};
if (!(!opt.exclude || !opt.exclude(_info))) {
_context.next = 22;
break;
}
_context.next = 22;
return _info;
case 22:
_i7++;
_context.next = 16;
break;
case 25:
_context.next = 28;
break;
case 27:
throw 'Unsupported type';
case 28:
_context.next = 58;
break;
case 30:
if (!(val.length != null)) {
_context.next = 42;
break;
}
_i8 = val.length - 1;
case 32:
if (!(_i8 >= 0)) {
_context.next = 40;
break;
}
_info2 = {
value: val[_i8],
index: _i8
};
if (!(!opt.exclude || !opt.exclude(_info2))) {
_context.next = 37;
break;
}
_context.next = 37;
return _info2;
case 37:
_i8--;
_context.next = 32;
break;
case 40:
_context.next = 58;
break;
case 42:
if (!isObject(val)) {
_context.next = 57;
break;
}
keys = Object.keys(val);
keys.reverse();
_i9 = 0, _keys2 = keys;
case 46:
if (!(_i9 < _keys2.length)) {
_context.next = 55;
break;
}
_key2 = _keys2[_i9];
_info3 = {
value: val[_key2],
key: _key2
};
if (!(!opt.exclude || !opt.exclude(_info3))) {
_context.next = 52;
break;
}
_context.next = 52;
return _info3;
case 52:
_i9++;
_context.next = 46;
break;
case 55:
_context.next = 58;
break;
case 57:
throw 'Unsupported type';
case 58:
case "end":
return _context.stop();
}
}
}, _marked);
} // source: http://stackoverflow.com/questions/8817394/javascript-get-deep-value-from-object-by-passing-path-to-it-as-string
function joinFunctionsByNext(funcs) {
var next = function next() {};
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator5 = iterateALL(funcs, {
reverse: true
})[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
var func = _step5.value.value;
var currentNext = next;
next = wrapFuncWithNext(func, currentNext);
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) {
_iterator5["return"]();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
return next;
function wrapFuncWithNext(func, next) {
return function () {
for (var _len5 = arguments.length, args = new Array(_len5), _key7 = 0; _key7 < _len5; _key7++) {
args[_key7] = arguments[_key7];
}
return func.apply(void 0, [next].concat(args));
};
}
} // promise
function onDOM(el, name, handler) {

@@ -53,3 +328,3 @@ for (var _len6 = arguments.length, args = new Array(_len6 > 3 ? _len6 - 3 : 0), _key8 = 3; _key8 < _len6; _key8++) {

var _marked =
var _marked$1 =
/*#__PURE__*/

@@ -59,6 +334,6 @@ regeneratorRuntime.mark(iterateObjectWithoutDollarDash);

* [updatablePropsEvenUnbound description]
* @param {[type]} props [un-circular object or getter]
* @param {[type]} props [object or getter]
* @return {[type]} [description]
* props eg: {
value: {localName: 'current'},
value: {$localName: 'current', $localSetter: (value, vm)},
}

@@ -71,4 +346,2 @@ default localName is `localProps_${name}`

props = props();
} else if (isArray(props)) {
props = props.slice();
} else {

@@ -79,25 +352,37 @@ // object

var component = {
props: props,
computed: {},
watch: {}
};
var propNames;
var localNames = {};
var standardProps = {}; // without key starts with `$`
if (isArray(props)) {
propNames = props;
} else {
propNames = [];
var _loop = function _loop(name) {
var prop = props[name]; // complete 补全选项
for (var key in props) {
propNames.push(key);
if (!prop.$localName) {
prop.$localName = "localProps_".concat(name);
}
if (props[key].localName) {
localNames[key] = props[key].localName;
delete props[key].localName;
if (!prop.$localSetter) {
prop.$localSetter = function (value) {
return value;
};
} // make standardProp
var standardProp = {};
standardProps[name] = standardProp;
Object.keys(props[name]).forEach(function (key) {
if (key[0] !== '$') {
standardProp[key] = prop[key];
}
}
});
};
for (var name in props) {
_loop(name);
}
var component = {
props: standardProps,
computed: {},
watch: {}
};
component.data = function () {

@@ -107,24 +392,6 @@ var t = {

};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = propNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var name = _step.value;
t.localValueOfUpdatableProps[name] = this[name];
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
for (var _i = 0, _Object$keys = Object.keys(props); _i < _Object$keys.length; _i++) {
var _name = _Object$keys[_i];
t.localValueOfUpdatableProps[_name] = this[_name];
}

@@ -135,47 +402,29 @@

var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
var _loop2 = function _loop2() {
var name = _Object$keys2[_i2];
var prop = props[name];
try {
var _loop = function _loop() {
var name = _step2.value;
component.watch[name] = function (value) {
this.localValueOfUpdatableProps[name] = prop.$localSetter(value, this);
};
component.watch[name] = function (value) {
this.localValueOfUpdatableProps[name] = value;
};
var localName = prop.$localName;
component.computed[localName] = {
get: function get() {
return this.localValueOfUpdatableProps[name];
},
set: function set(value) {
if (name === 'value') {
this.$emit('input', value);
} else {
this.$emit("update:".concat(name), value);
}
var localName = localNames[name] || "localProps_".concat(name);
component.computed[localName] = {
get: function get() {
return this.localValueOfUpdatableProps[name];
},
set: function set(value) {
if (name === 'value') {
this.$emit('input', value);
} else {
this.$emit("update:".concat(name), value);
}
this.localValueOfUpdatableProps[name] = value;
}
};
this.localValueOfUpdatableProps[name] = prop.$localSetter(value, this);
}
};
};
for (var _iterator2 = propNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
_loop();
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
_iterator2["return"]();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
for (var _i2 = 0, _Object$keys2 = Object.keys(props); _i2 < _Object$keys2.length; _i2++) {
_loop2();
}

@@ -310,3 +559,3 @@

}
}, _marked);
}, _marked$1);
} // add reactive `windowSize`

@@ -389,4 +638,56 @@

}
var hookHelper = {
methods: {
// todo extract hooks to vue-functions
// get hooks in this._hooks, without which in props
_getNonPropHooksByName: function _getNonPropHooksByName(name) {
if (this._hooks) {
return this._hooks[name];
}
},
addHook: function addHook(name, func) {
if (!this._getNonPropHooksByName(name)) {
if (!this._hooks) {
this._hooks = {};
}
if (!this._hooks[name]) {
this._hooks[name] = [];
}
}
this._hooks[name].push(func);
},
removeHook: function removeHook(name, func) {
var hooks = this._getNonPropHooksByName(name);
if (hooks) {
arrayRemove(hooks, func);
}
},
hasHook: function hasHook(name) {
return this._getNonPropHooksByName(name) || this[name];
},
executeHook: function executeHook(name, args) {
var hooks = this._getNonPropHooksByName(name).slice();
if (hooks) {
if (this[name] && isFunction(this[name])) {
hooks.push(function (next) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return this[name].apply(this, args);
});
}
return joinFunctionsByNext(hooks).apply(void 0, _toConsumableArray(args));
}
}
}
};
exports.doWatch = doWatch;
exports.hookHelper = hookHelper;
exports.isPropTrue = isPropTrue;

@@ -393,0 +694,0 @@ exports.iterateObjectWithoutDollarDash = iterateObjectWithoutDollarDash;

/*!
* vue-functions v1.0.6
* vue-functions v2.0.0
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)
* Released under the MIT License.
*/
function isArray(v) {
return Object.prototype.toString.call(v) === '[object Array]';
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
var _marked =
/*#__PURE__*/
regeneratorRuntime.mark(iterateALL); // local store
function isObject(v) {
return Object.prototype.toString.call(v) === '[object Object]';
}
function isFunction(v) {

@@ -19,2 +43,253 @@ return typeof v === 'function';

function arrayRemove(arr, v) {
var index;
var count = 0;
while ((index = arr.indexOf(v)) > -1) {
arr.splice(index, 1);
count++;
}
return count;
}
function iterateALL(val) {
var opt,
i,
info,
_i7,
_Object$keys2,
key,
_info,
_i8,
_info2,
keys,
_i9,
_keys2,
_key2,
_info3,
_args = arguments;
return regeneratorRuntime.wrap(function iterateALL$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
opt = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
if (opt.reverse) {
_context.next = 30;
break;
}
if (!(val.length != null)) {
_context.next = 14;
break;
}
i = 0;
case 4:
if (!(i < val.length)) {
_context.next = 12;
break;
}
info = {
value: val[i],
index: i
};
if (!(!opt.exclude || !opt.exclude(info))) {
_context.next = 9;
break;
}
_context.next = 9;
return info;
case 9:
i++;
_context.next = 4;
break;
case 12:
_context.next = 28;
break;
case 14:
if (!isObject(val)) {
_context.next = 27;
break;
}
_i7 = 0, _Object$keys2 = Object.keys(val);
case 16:
if (!(_i7 < _Object$keys2.length)) {
_context.next = 25;
break;
}
key = _Object$keys2[_i7];
_info = {
value: val[key],
key: key
};
if (!(!opt.exclude || !opt.exclude(_info))) {
_context.next = 22;
break;
}
_context.next = 22;
return _info;
case 22:
_i7++;
_context.next = 16;
break;
case 25:
_context.next = 28;
break;
case 27:
throw 'Unsupported type';
case 28:
_context.next = 58;
break;
case 30:
if (!(val.length != null)) {
_context.next = 42;
break;
}
_i8 = val.length - 1;
case 32:
if (!(_i8 >= 0)) {
_context.next = 40;
break;
}
_info2 = {
value: val[_i8],
index: _i8
};
if (!(!opt.exclude || !opt.exclude(_info2))) {
_context.next = 37;
break;
}
_context.next = 37;
return _info2;
case 37:
_i8--;
_context.next = 32;
break;
case 40:
_context.next = 58;
break;
case 42:
if (!isObject(val)) {
_context.next = 57;
break;
}
keys = Object.keys(val);
keys.reverse();
_i9 = 0, _keys2 = keys;
case 46:
if (!(_i9 < _keys2.length)) {
_context.next = 55;
break;
}
_key2 = _keys2[_i9];
_info3 = {
value: val[_key2],
key: _key2
};
if (!(!opt.exclude || !opt.exclude(_info3))) {
_context.next = 52;
break;
}
_context.next = 52;
return _info3;
case 52:
_i9++;
_context.next = 46;
break;
case 55:
_context.next = 58;
break;
case 57:
throw 'Unsupported type';
case 58:
case "end":
return _context.stop();
}
}
}, _marked);
} // source: http://stackoverflow.com/questions/8817394/javascript-get-deep-value-from-object-by-passing-path-to-it-as-string
function joinFunctionsByNext(funcs) {
var next = function next() {};
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator5 = iterateALL(funcs, {
reverse: true
})[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
var func = _step5.value.value;
var currentNext = next;
next = wrapFuncWithNext(func, currentNext);
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) {
_iterator5["return"]();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
return next;
function wrapFuncWithNext(func, next) {
return function () {
for (var _len5 = arguments.length, args = new Array(_len5), _key7 = 0; _key7 < _len5; _key7++) {
args[_key7] = arguments[_key7];
}
return func.apply(void 0, [next].concat(args));
};
}
} // promise
function onDOM(el, name, handler) {

@@ -48,3 +323,3 @@ for (var _len6 = arguments.length, args = new Array(_len6 > 3 ? _len6 - 3 : 0), _key8 = 3; _key8 < _len6; _key8++) {

var _marked =
var _marked$1 =
/*#__PURE__*/

@@ -54,6 +329,6 @@ regeneratorRuntime.mark(iterateObjectWithoutDollarDash);

* [updatablePropsEvenUnbound description]
* @param {[type]} props [un-circular object or getter]
* @param {[type]} props [object or getter]
* @return {[type]} [description]
* props eg: {
value: {localName: 'current'},
value: {$localName: 'current', $localSetter: (value, vm)},
}

@@ -66,4 +341,2 @@ default localName is `localProps_${name}`

props = props();
} else if (isArray(props)) {
props = props.slice();
} else {

@@ -74,25 +347,37 @@ // object

var component = {
props: props,
computed: {},
watch: {}
};
var propNames;
var localNames = {};
var standardProps = {}; // without key starts with `$`
if (isArray(props)) {
propNames = props;
} else {
propNames = [];
var _loop = function _loop(name) {
var prop = props[name]; // complete 补全选项
for (var key in props) {
propNames.push(key);
if (!prop.$localName) {
prop.$localName = "localProps_".concat(name);
}
if (props[key].localName) {
localNames[key] = props[key].localName;
delete props[key].localName;
if (!prop.$localSetter) {
prop.$localSetter = function (value) {
return value;
};
} // make standardProp
var standardProp = {};
standardProps[name] = standardProp;
Object.keys(props[name]).forEach(function (key) {
if (key[0] !== '$') {
standardProp[key] = prop[key];
}
}
});
};
for (var name in props) {
_loop(name);
}
var component = {
props: standardProps,
computed: {},
watch: {}
};
component.data = function () {

@@ -102,24 +387,6 @@ var t = {

};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = propNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var name = _step.value;
t.localValueOfUpdatableProps[name] = this[name];
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
for (var _i = 0, _Object$keys = Object.keys(props); _i < _Object$keys.length; _i++) {
var _name = _Object$keys[_i];
t.localValueOfUpdatableProps[_name] = this[_name];
}

@@ -130,47 +397,29 @@

var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
var _loop2 = function _loop2() {
var name = _Object$keys2[_i2];
var prop = props[name];
try {
var _loop = function _loop() {
var name = _step2.value;
component.watch[name] = function (value) {
this.localValueOfUpdatableProps[name] = prop.$localSetter(value, this);
};
component.watch[name] = function (value) {
this.localValueOfUpdatableProps[name] = value;
};
var localName = prop.$localName;
component.computed[localName] = {
get: function get() {
return this.localValueOfUpdatableProps[name];
},
set: function set(value) {
if (name === 'value') {
this.$emit('input', value);
} else {
this.$emit("update:".concat(name), value);
}
var localName = localNames[name] || "localProps_".concat(name);
component.computed[localName] = {
get: function get() {
return this.localValueOfUpdatableProps[name];
},
set: function set(value) {
if (name === 'value') {
this.$emit('input', value);
} else {
this.$emit("update:".concat(name), value);
}
this.localValueOfUpdatableProps[name] = value;
}
};
this.localValueOfUpdatableProps[name] = prop.$localSetter(value, this);
}
};
};
for (var _iterator2 = propNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
_loop();
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
_iterator2["return"]();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
for (var _i2 = 0, _Object$keys2 = Object.keys(props); _i2 < _Object$keys2.length; _i2++) {
_loop2();
}

@@ -305,3 +554,3 @@

}
}, _marked);
}, _marked$1);
} // add reactive `windowSize`

@@ -384,3 +633,54 @@

}
var hookHelper = {
methods: {
// todo extract hooks to vue-functions
// get hooks in this._hooks, without which in props
_getNonPropHooksByName: function _getNonPropHooksByName(name) {
if (this._hooks) {
return this._hooks[name];
}
},
addHook: function addHook(name, func) {
if (!this._getNonPropHooksByName(name)) {
if (!this._hooks) {
this._hooks = {};
}
export { doWatch, isPropTrue, iterateObjectWithoutDollarDash, registerPreventURLChange, updatablePropsEvenUnbound, watchAsync, windowSize };
if (!this._hooks[name]) {
this._hooks[name] = [];
}
}
this._hooks[name].push(func);
},
removeHook: function removeHook(name, func) {
var hooks = this._getNonPropHooksByName(name);
if (hooks) {
arrayRemove(hooks, func);
}
},
hasHook: function hasHook(name) {
return this._getNonPropHooksByName(name) || this[name];
},
executeHook: function executeHook(name, args) {
var hooks = this._getNonPropHooksByName(name).slice();
if (hooks) {
if (this[name] && isFunction(this[name])) {
hooks.push(function (next) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return this[name].apply(this, args);
});
}
return joinFunctionsByNext(hooks).apply(void 0, _toConsumableArray(args));
}
}
}
};
export { doWatch, hookHelper, isPropTrue, iterateObjectWithoutDollarDash, registerPreventURLChange, updatablePropsEvenUnbound, watchAsync, windowSize };
/*!
* vue-functions v1.0.6
* vue-functions v2.0.0
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)

@@ -12,6 +12,30 @@ * Released under the MIT License.

function isArray(v) {
return Object.prototype.toString.call(v) === '[object Array]';
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
var _marked =
/*#__PURE__*/
regeneratorRuntime.mark(iterateALL); // local store
function isObject(v) {
return Object.prototype.toString.call(v) === '[object Object]';
}
function isFunction(v) {

@@ -26,2 +50,253 @@ return typeof v === 'function';

function arrayRemove(arr, v) {
var index;
var count = 0;
while ((index = arr.indexOf(v)) > -1) {
arr.splice(index, 1);
count++;
}
return count;
}
function iterateALL(val) {
var opt,
i,
info,
_i7,
_Object$keys2,
key,
_info,
_i8,
_info2,
keys,
_i9,
_keys2,
_key2,
_info3,
_args = arguments;
return regeneratorRuntime.wrap(function iterateALL$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
opt = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
if (opt.reverse) {
_context.next = 30;
break;
}
if (!(val.length != null)) {
_context.next = 14;
break;
}
i = 0;
case 4:
if (!(i < val.length)) {
_context.next = 12;
break;
}
info = {
value: val[i],
index: i
};
if (!(!opt.exclude || !opt.exclude(info))) {
_context.next = 9;
break;
}
_context.next = 9;
return info;
case 9:
i++;
_context.next = 4;
break;
case 12:
_context.next = 28;
break;
case 14:
if (!isObject(val)) {
_context.next = 27;
break;
}
_i7 = 0, _Object$keys2 = Object.keys(val);
case 16:
if (!(_i7 < _Object$keys2.length)) {
_context.next = 25;
break;
}
key = _Object$keys2[_i7];
_info = {
value: val[key],
key: key
};
if (!(!opt.exclude || !opt.exclude(_info))) {
_context.next = 22;
break;
}
_context.next = 22;
return _info;
case 22:
_i7++;
_context.next = 16;
break;
case 25:
_context.next = 28;
break;
case 27:
throw 'Unsupported type';
case 28:
_context.next = 58;
break;
case 30:
if (!(val.length != null)) {
_context.next = 42;
break;
}
_i8 = val.length - 1;
case 32:
if (!(_i8 >= 0)) {
_context.next = 40;
break;
}
_info2 = {
value: val[_i8],
index: _i8
};
if (!(!opt.exclude || !opt.exclude(_info2))) {
_context.next = 37;
break;
}
_context.next = 37;
return _info2;
case 37:
_i8--;
_context.next = 32;
break;
case 40:
_context.next = 58;
break;
case 42:
if (!isObject(val)) {
_context.next = 57;
break;
}
keys = Object.keys(val);
keys.reverse();
_i9 = 0, _keys2 = keys;
case 46:
if (!(_i9 < _keys2.length)) {
_context.next = 55;
break;
}
_key2 = _keys2[_i9];
_info3 = {
value: val[_key2],
key: _key2
};
if (!(!opt.exclude || !opt.exclude(_info3))) {
_context.next = 52;
break;
}
_context.next = 52;
return _info3;
case 52:
_i9++;
_context.next = 46;
break;
case 55:
_context.next = 58;
break;
case 57:
throw 'Unsupported type';
case 58:
case "end":
return _context.stop();
}
}
}, _marked);
} // source: http://stackoverflow.com/questions/8817394/javascript-get-deep-value-from-object-by-passing-path-to-it-as-string
function joinFunctionsByNext(funcs) {
var next = function next() {};
var _iteratorNormalCompletion5 = true;
var _didIteratorError5 = false;
var _iteratorError5 = undefined;
try {
for (var _iterator5 = iterateALL(funcs, {
reverse: true
})[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
var func = _step5.value.value;
var currentNext = next;
next = wrapFuncWithNext(func, currentNext);
}
} catch (err) {
_didIteratorError5 = true;
_iteratorError5 = err;
} finally {
try {
if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) {
_iterator5["return"]();
}
} finally {
if (_didIteratorError5) {
throw _iteratorError5;
}
}
}
return next;
function wrapFuncWithNext(func, next) {
return function () {
for (var _len5 = arguments.length, args = new Array(_len5), _key7 = 0; _key7 < _len5; _key7++) {
args[_key7] = arguments[_key7];
}
return func.apply(void 0, [next].concat(args));
};
}
} // promise
function onDOM(el, name, handler) {

@@ -55,3 +330,3 @@ for (var _len6 = arguments.length, args = new Array(_len6 > 3 ? _len6 - 3 : 0), _key8 = 3; _key8 < _len6; _key8++) {

var _marked =
var _marked$1 =
/*#__PURE__*/

@@ -61,6 +336,6 @@ regeneratorRuntime.mark(iterateObjectWithoutDollarDash);

* [updatablePropsEvenUnbound description]
* @param {[type]} props [un-circular object or getter]
* @param {[type]} props [object or getter]
* @return {[type]} [description]
* props eg: {
value: {localName: 'current'},
value: {$localName: 'current', $localSetter: (value, vm)},
}

@@ -73,4 +348,2 @@ default localName is `localProps_${name}`

props = props();
} else if (isArray(props)) {
props = props.slice();
} else {

@@ -81,25 +354,37 @@ // object

var component = {
props: props,
computed: {},
watch: {}
};
var propNames;
var localNames = {};
var standardProps = {}; // without key starts with `$`
if (isArray(props)) {
propNames = props;
} else {
propNames = [];
var _loop = function _loop(name) {
var prop = props[name]; // complete 补全选项
for (var key in props) {
propNames.push(key);
if (!prop.$localName) {
prop.$localName = "localProps_".concat(name);
}
if (props[key].localName) {
localNames[key] = props[key].localName;
delete props[key].localName;
if (!prop.$localSetter) {
prop.$localSetter = function (value) {
return value;
};
} // make standardProp
var standardProp = {};
standardProps[name] = standardProp;
Object.keys(props[name]).forEach(function (key) {
if (key[0] !== '$') {
standardProp[key] = prop[key];
}
}
});
};
for (var name in props) {
_loop(name);
}
var component = {
props: standardProps,
computed: {},
watch: {}
};
component.data = function () {

@@ -109,24 +394,6 @@ var t = {

};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = propNames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var name = _step.value;
t.localValueOfUpdatableProps[name] = this[name];
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
for (var _i = 0, _Object$keys = Object.keys(props); _i < _Object$keys.length; _i++) {
var _name = _Object$keys[_i];
t.localValueOfUpdatableProps[_name] = this[_name];
}

@@ -137,47 +404,29 @@

var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
var _loop2 = function _loop2() {
var name = _Object$keys2[_i2];
var prop = props[name];
try {
var _loop = function _loop() {
var name = _step2.value;
component.watch[name] = function (value) {
this.localValueOfUpdatableProps[name] = prop.$localSetter(value, this);
};
component.watch[name] = function (value) {
this.localValueOfUpdatableProps[name] = value;
};
var localName = prop.$localName;
component.computed[localName] = {
get: function get() {
return this.localValueOfUpdatableProps[name];
},
set: function set(value) {
if (name === 'value') {
this.$emit('input', value);
} else {
this.$emit("update:".concat(name), value);
}
var localName = localNames[name] || "localProps_".concat(name);
component.computed[localName] = {
get: function get() {
return this.localValueOfUpdatableProps[name];
},
set: function set(value) {
if (name === 'value') {
this.$emit('input', value);
} else {
this.$emit("update:".concat(name), value);
}
this.localValueOfUpdatableProps[name] = value;
}
};
this.localValueOfUpdatableProps[name] = prop.$localSetter(value, this);
}
};
};
for (var _iterator2 = propNames[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
_loop();
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
_iterator2["return"]();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
for (var _i2 = 0, _Object$keys2 = Object.keys(props); _i2 < _Object$keys2.length; _i2++) {
_loop2();
}

@@ -312,3 +561,3 @@

}
}, _marked);
}, _marked$1);
} // add reactive `windowSize`

@@ -391,4 +640,56 @@

}
var hookHelper = {
methods: {
// todo extract hooks to vue-functions
// get hooks in this._hooks, without which in props
_getNonPropHooksByName: function _getNonPropHooksByName(name) {
if (this._hooks) {
return this._hooks[name];
}
},
addHook: function addHook(name, func) {
if (!this._getNonPropHooksByName(name)) {
if (!this._hooks) {
this._hooks = {};
}
if (!this._hooks[name]) {
this._hooks[name] = [];
}
}
this._hooks[name].push(func);
},
removeHook: function removeHook(name, func) {
var hooks = this._getNonPropHooksByName(name);
if (hooks) {
arrayRemove(hooks, func);
}
},
hasHook: function hasHook(name) {
return this._getNonPropHooksByName(name) || this[name];
},
executeHook: function executeHook(name, args) {
var hooks = this._getNonPropHooksByName(name).slice();
if (hooks) {
if (this[name] && isFunction(this[name])) {
hooks.push(function (next) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return this[name].apply(this, args);
});
}
return joinFunctionsByNext(hooks).apply(void 0, _toConsumableArray(args));
}
}
}
};
exports.doWatch = doWatch;
exports.hookHelper = hookHelper;
exports.isPropTrue = isPropTrue;

@@ -395,0 +696,0 @@ exports.iterateObjectWithoutDollarDash = iterateObjectWithoutDollarDash;

4

dist/vue-functions.min.js
/*!
* vue-functions v1.0.6
* vue-functions v2.0.0
* (c) phphe <phphe@outlook.com> (https://github.com/phphe)
* Released under the MIT License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).vueFunctions={})}(this,(function(e){"use strict";function t(e){return"[object Array]"===Object.prototype.toString.call(e)}var n=regeneratorRuntime.mark(o);function o(e){var t,o;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:n.t0=regeneratorRuntime.keys(e);case 1:if((n.t1=n.t0()).done){n.next=9;break}if(t=n.t1.value,"$"===(o=t.substr(0,1))||"_"===o){n.next=7;break}return n.next=7,{key:t,value:e[t]};case 7:n.next=1;break;case 9:case"end":return n.stop()}}),n)}var r={data:function(){return{windowSize:{innerWidth:window.innerWidth,innerHeight:window.innerHeight,outerWidth:window.outerWidth,outerHeight:window.outerHeight}}},methods:{updateWindowSize:function(){Object.assign(this.windowSize,{innerWidth:window.innerWidth,innerHeight:window.innerHeight,outerWidth:window.outerWidth,outerHeight:window.outerHeight})}},created:function(){var e=this;this._windowSize_onresize=function(){e.updateWindowSize(),e.$emit("window-resize")},function(e,t,n){for(var o=arguments.length,r=new Array(o>3?o-3:0),i=3;i<o;i++)r[i-3]=arguments[i];e.addEventListener?e.addEventListener.apply(e,[t,n].concat(r)):e.attachEvent&&e.attachEvent.apply(e,["on".concat(t),n].concat(r))}(window,"resize",this._windowSize_onresize)},beforeDestroy:function(){!function(e,t,n){for(var o=arguments.length,r=new Array(o>3?o-3:0),i=3;i<o;i++)r[i-3]=arguments[i];e.removeEventListener?e.removeEventListener.apply(e,[t,n].concat(r)):e.detachEvent&&e.detachEvent.apply(e,["on".concat(t),n].concat(r))}(window,"resize",this._windowSize_onresize)}};e.doWatch=function(e,t){var n,o;return function r(){var i=t.call(e,n);o=e.$watch(i,(function(e){o(),n=e,r()}))}(),function(){return o&&o()}},e.isPropTrue=function(e){return""===e||e},e.iterateObjectWithoutDollarDash=o,e.registerPreventURLChange=function(e,t,n){var o=!1,r="It looks like you have been editing something.\nIf you leave before saving, your changes will be lost.";t.beforeEach((function(t,i,a){o?window.confirm(n||r)?(e.allowURLChange(),a()):a(!1):a()}));var i=function(e){var t=n||r;return e.returnValue=t,t};e.preventURLChange=e.prototype.$preventURLChange=function(e){null!=e&&(n=e),o||(o=!0,window.addEventListener("beforeunload",i))},e.allowURLChange=e.prototype.$allowURLChange=function(){o=!1,window.removeEventListener("beforeunload",i)}},e.updatablePropsEvenUnbound=function(e){var n,o={props:e="function"==typeof e?e():t(e)?e.slice():Object.assign({},e),computed:{},watch:{}},r={};if(t(e))n=e;else for(var i in n=[],e)n.push(i),e[i].localName&&(r[i]=e[i].localName,delete e[i].localName);o.data=function(){var e={localValueOfUpdatableProps:{}},t=!0,o=!1,r=void 0;try{for(var i,a=n[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var c=i.value;e.localValueOfUpdatableProps[c]=this[c]}}catch(e){o=!0,r=e}finally{try{t||null==a.return||a.return()}finally{if(o)throw r}}return e};var a=!0,c=!1,u=void 0;try{for(var l,d=function(){var e=l.value;o.watch[e]=function(t){this.localValueOfUpdatableProps[e]=t};var t=r[e]||"localProps_".concat(e);o.computed[t]={get:function(){return this.localValueOfUpdatableProps[e]},set:function(t){"value"===e?this.$emit("input",t):this.$emit("update:".concat(e),t),this.localValueOfUpdatableProps[e]=t}}},f=n[Symbol.iterator]();!(a=(l=f.next()).done);a=!0)d()}catch(e){c=!0,u=e}finally{try{a||null==f.return||f.return()}finally{if(c)throw u}}return o},e.watchAsync=function(e,t,n,o){var r,i,a=[],c=-1;return d(),u;function u(){a.forEach((function(e){return e()})),a=[]}function l(t,n){var o,r=!0,i=e.$watch((function(){return t.call(e,l)}),(function(e){o=e,r?r=!1:d()}),{immediate:!0,deep:n&&n.deep});return a.push(i),o}function d(){u();var a=t.call(e,l),d=++c;i=r;var f,s=function(t){d===c&&(0===d?o&&o.immediate&&n.call(e,t,i):n.call(e,t,i))};f=a,"[object Promise]"===Object.prototype.toString.call(f)?a.then(s):s(a)}},e.windowSize=r,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).vueFunctions={})}(this,(function(e){"use strict";function t(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var n=regeneratorRuntime.mark(a);function r(e){return"[object Object]"===Object.prototype.toString.call(e)}function o(e){return"function"==typeof e}function a(e){var t,o,a,i,c,u,s,l,f,h,d,p,v,w,b=arguments;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if((t=b.length>1&&void 0!==b[1]?b[1]:{}).reverse){n.next=30;break}if(null==e.length){n.next=14;break}o=0;case 4:if(!(o<e.length)){n.next=12;break}if(a={value:e[o],index:o},t.exclude&&t.exclude(a)){n.next=9;break}return n.next=9,a;case 9:o++,n.next=4;break;case 12:n.next=28;break;case 14:if(!r(e)){n.next=27;break}i=0,c=Object.keys(e);case 16:if(!(i<c.length)){n.next=25;break}if(u=c[i],s={value:e[u],key:u},t.exclude&&t.exclude(s)){n.next=22;break}return n.next=22,s;case 22:i++,n.next=16;break;case 25:n.next=28;break;case 27:throw"Unsupported type";case 28:n.next=58;break;case 30:if(null==e.length){n.next=42;break}l=e.length-1;case 32:if(!(l>=0)){n.next=40;break}if(f={value:e[l],index:l},t.exclude&&t.exclude(f)){n.next=37;break}return n.next=37,f;case 37:l--,n.next=32;break;case 40:n.next=58;break;case 42:if(!r(e)){n.next=57;break}(h=Object.keys(e)).reverse(),d=0,p=h;case 46:if(!(d<p.length)){n.next=55;break}if(v=p[d],w={value:e[v],key:v},t.exclude&&t.exclude(w)){n.next=52;break}return n.next=52,w;case 52:d++,n.next=46;break;case 55:n.next=58;break;case 57:throw"Unsupported type";case 58:case"end":return n.stop()}}),n)}var i=regeneratorRuntime.mark(c);function c(e){var t,n;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:r.t0=regeneratorRuntime.keys(e);case 1:if((r.t1=r.t0()).done){r.next=9;break}if(t=r.t1.value,"$"===(n=t.substr(0,1))||"_"===n){r.next=7;break}return r.next=7,{key:t,value:e[t]};case 7:r.next=1;break;case 9:case"end":return r.stop()}}),i)}var u={data:function(){return{windowSize:{innerWidth:window.innerWidth,innerHeight:window.innerHeight,outerWidth:window.outerWidth,outerHeight:window.outerHeight}}},methods:{updateWindowSize:function(){Object.assign(this.windowSize,{innerWidth:window.innerWidth,innerHeight:window.innerHeight,outerWidth:window.outerWidth,outerHeight:window.outerHeight})}},created:function(){var e=this;this._windowSize_onresize=function(){e.updateWindowSize(),e.$emit("window-resize")},function(e,t,n){for(var r=arguments.length,o=new Array(r>3?r-3:0),a=3;a<r;a++)o[a-3]=arguments[a];e.addEventListener?e.addEventListener.apply(e,[t,n].concat(o)):e.attachEvent&&e.attachEvent.apply(e,["on".concat(t),n].concat(o))}(window,"resize",this._windowSize_onresize)},beforeDestroy:function(){!function(e,t,n){for(var r=arguments.length,o=new Array(r>3?r-3:0),a=3;a<r;a++)o[a-3]=arguments[a];e.removeEventListener?e.removeEventListener.apply(e,[t,n].concat(o)):e.detachEvent&&e.detachEvent.apply(e,["on".concat(t),n].concat(o))}(window,"resize",this._windowSize_onresize)}};var s={methods:{_getNonPropHooksByName:function(e){if(this._hooks)return this._hooks[e]},addHook:function(e,t){this._getNonPropHooksByName(e)||(this._hooks||(this._hooks={}),this._hooks[e]||(this._hooks[e]=[])),this._hooks[e].push(t)},removeHook:function(e,t){var n=this._getNonPropHooksByName(e);n&&function(e,t){for(var n,r=0;(n=e.indexOf(t))>-1;)e.splice(n,1),r++}(n,t)},hasHook:function(e){return this._getNonPropHooksByName(e)||this[e]},executeHook:function(e,n){var r=this._getNonPropHooksByName(e).slice();if(r)return this[e]&&o(this[e])&&r.push((function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return this[e].apply(this,r)})),function(e){var t=function(){},n=!0,r=!1,o=void 0;try{for(var i,c=a(e,{reverse:!0})[Symbol.iterator]();!(n=(i=c.next()).done);n=!0){t=u(i.value.value,t)}}catch(e){r=!0,o=e}finally{try{n||null==c.return||c.return()}finally{if(r)throw o}}return t;function u(e,t){return function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e.apply(void 0,[t].concat(r))}}}(r).apply(void 0,t(n))}}};e.doWatch=function(e,t){var n,r;return function o(){var a=t.call(e,n);r=e.$watch(a,(function(e){r(),n=e,o()}))}(),function(){return r&&r()}},e.hookHelper=s,e.isPropTrue=function(e){return""===e||e},e.iterateObjectWithoutDollarDash=c,e.registerPreventURLChange=function(e,t,n){var r=!1,o="It looks like you have been editing something.\nIf you leave before saving, your changes will be lost.";t.beforeEach((function(t,a,i){r?window.confirm(n||o)?(e.allowURLChange(),i()):i(!1):i()}));var a=function(e){var t=n||o;return e.returnValue=t,t};e.preventURLChange=e.prototype.$preventURLChange=function(e){null!=e&&(n=e),r||(r=!0,window.addEventListener("beforeunload",a))},e.allowURLChange=e.prototype.$allowURLChange=function(){r=!1,window.removeEventListener("beforeunload",a)}},e.updatablePropsEvenUnbound=function(e){e=o(e)?e():Object.assign({},e);var t={},n=function(n){var r=e[n];r.$localName||(r.$localName="localProps_".concat(n)),r.$localSetter||(r.$localSetter=function(e){return e});var o={};t[n]=o,Object.keys(e[n]).forEach((function(e){"$"!==e[0]&&(o[e]=r[e])}))};for(var r in e)n(r);for(var a={props:t,computed:{},watch:{},data:function(){for(var t={localValueOfUpdatableProps:{}},n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];t.localValueOfUpdatableProps[o]=this[o]}return t}},i=function(){var t=u[c],n=e[t];a.watch[t]=function(e){this.localValueOfUpdatableProps[t]=n.$localSetter(e,this)};var r=n.$localName;a.computed[r]={get:function(){return this.localValueOfUpdatableProps[t]},set:function(e){"value"===t?this.$emit("input",e):this.$emit("update:".concat(t),e),this.localValueOfUpdatableProps[t]=n.$localSetter(e,this)}}},c=0,u=Object.keys(e);c<u.length;c++)i();return a},e.watchAsync=function(e,t,n,r){var o,a,i=[],c=-1;return l(),u;function u(){i.forEach((function(e){return e()})),i=[]}function s(t,n){var r,o=!0,a=e.$watch((function(){return t.call(e,s)}),(function(e){r=e,o?o=!1:l()}),{immediate:!0,deep:n&&n.deep});return i.push(a),r}function l(){u();var i=t.call(e,s),l=++c;a=o;var f,h=function(t){l===c&&(0===l?r&&r.immediate&&n.call(e,t,a):n.call(e,t,a))};f=i,"[object Promise]"===Object.prototype.toString.call(f)?i.then(h):h(i)}},e.windowSize=u,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=vue-functions.min.js.map
{
"name": "vue-functions",
"version": "1.0.6",
"version": "2.0.0",
"description": "",

@@ -28,5 +28,5 @@ "main": "dist/vue-functions.cjs.js",

"dependencies": {
"helper-js": "^1.4.14"
"helper-js": "^1.4.15"
},
"license": "MIT"
}

@@ -59,1 +59,12 @@ # vue-functions

Attach `$preventURLChange` and `$allowURLChange` to vm.
### hookHelper
Vue component, extend or mixin it to use. Help to extend hook.
```js
methods: {
addHook(name, func),
removeHook(name, func),
hasHook(name),
executeHook(name, args)
}
```

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