Socket
Socket
Sign inDemoInstall

spy4js

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spy4js - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

93

dist/serializer.js

@@ -8,10 +8,79 @@ 'use strict';

var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _utils = require('./utils');
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } /**
* This file is part of spy4js which is released under MIT license.
*
* The LICENSE file can be found in the root directory of this project.
*
*
*/
var _utils = require('./utils');
var __serializeProp = function __serializeProp(key, value) {
return typeof value === 'string' ? key + '="' + value + '"' : key + '={' + __serialize(value) + '}';
};
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var __serializeProps = function __serializeProps(o, key, ref) {
var props = [];
(0, _utils.forEach)(o, function (k, v) {
if (v !== undefined && k !== 'children') props.push(__serializeProp(k, v));
});
if (key) props.push(__serializeProp('key', key));
if (ref) props.push(__serializeProp('ref', ref));
if (!props.length) return '';
return ' ' + props.join(' ');
};
var __serializeChildren = function __serializeChildren(o) {
var children = o.props.children;
if (!children) return '';
if (typeof children === 'string') return children;
return Array.isArray(children) ? children.map(function (v) {
return __serialize(v);
}).join('') : __serialize(children);
};
var getTypeName = function getTypeName(type) {
var typeType = Object.prototype.toString.call(type);
switch (typeType) {
case '[object Symbol]':
if (Symbol.keyFor(type) === 'react.fragment') return 'Fragment';
return;
case '[object String]':
return type;
case '[object Function]':
return type.name;
default:
return;
}
};
var __serializeReactElement = function __serializeReactElement(o) {
var type = getTypeName(o.type) || 'UNKNOWN';
// the following line would serialize custom react components deep instead of shallow (but its out-commented
// because usually it is more helpful to see what was provided)
// if (typeof o.type === 'function') return __serialize(new o.type(o.props).render());
var children = __serializeChildren(o);
var firstPart = '<' + type + __serializeProps(o.props, o.key, o.ref);
var lastPart = children ? '>' + children + '</' + type + '>' : ' />';
return firstPart + lastPart;
};
var __serializeReact = function __serializeReact(o) {
var symbolKey = Symbol.keyFor(o.$$typeof);
switch (symbolKey) {
case 'react.element':
return __serializeReactElement(o);
default:
return;
}
};
var __serializeIfReact = function __serializeIfReact(o) {
if (Object.prototype.toString.call(o.$$typeof) === '[object Symbol]') {
var key = Symbol.keyFor(o.$$typeof);
if (key && key.indexOf('react.') === 0) return __serializeReact(o);
}
};
var __serialize = function __serialize(o) {

@@ -29,2 +98,6 @@ var alreadySerialized = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];

}
// check if its serializable as react jsx
var react = __serializeIfReact(o);
if (react) return react; // was serialized successful -> return it
var oClass = Object.prototype.toString.call(o);

@@ -37,3 +110,3 @@ switch (oClass) {

case '[object Function]':
return 'Function';
return o.name || 'Function';
case '[object Date]':

@@ -51,3 +124,3 @@ return '>Date:' + Number(o) + '<';

}
var serialized = [].concat((0, _toConsumableArray3.default)(alreadySerialized), [o]);
var serialized = [].concat(_toConsumableArray(alreadySerialized), [o]);
if (oClass === '[object Array]') {

@@ -70,9 +143,3 @@ var _results = [];

return displayedType + '{' + results.join(', ') + '}';
}; /**
* This file is part of spy4js which is released under MIT license.
*
* The LICENSE file can be found in the root directory of this project.
*
*
*/
};

@@ -79,0 +146,0 @@ var serialize = exports.serialize = function serialize(o) {

18

dist/spy.js

@@ -8,6 +8,2 @@ 'use strict';

var _symbol = require('babel-runtime/core-js/symbol');
var _symbol2 = _interopRequireDefault(_symbol);
var _utils = require('./utils');

@@ -19,4 +15,2 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -43,8 +37,8 @@ *

var Symbols = {
name: (0, _symbol2.default)('__Spy_name__'),
isSpy: (0, _symbol2.default)('__Spy_isSpy__'),
func: (0, _symbol2.default)('__Spy_func__'),
calls: (0, _symbol2.default)('__Spy_calls__'),
config: (0, _symbol2.default)('__Spy_config__'),
index: (0, _symbol2.default)('__Spy_config__')
name: Symbol.for('__Spy_name__'),
isSpy: Symbol.for('__Spy_isSpy__'),
func: Symbol.for('__Spy_func__'),
calls: Symbol.for('__Spy_calls__'),
config: Symbol.for('__Spy_config__'),
index: Symbol.for('__Spy_index__')
};

@@ -51,0 +45,0 @@

@@ -6,14 +6,5 @@ 'use strict';

});
exports.IGNORE = exports.objectKeys = exports.forEach = exports.differenceOf = undefined;
var _symbol = require('babel-runtime/core-js/symbol');
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var _symbol2 = _interopRequireDefault(_symbol);
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -78,3 +69,3 @@ * This file is part of spy4js which is released under MIT license.

var mergeArrays = function mergeArrays(arr1, arr2) {
var result = [].concat((0, _toConsumableArray3.default)(arr1));
var result = [].concat(_toConsumableArray(arr1));
forEach(arr2, function (key, val) {

@@ -92,3 +83,3 @@ if (arr1.indexOf(val) === -1) {

*/
var IGNORE = (0, _symbol2.default)('__Spy_IGNORE__');
var IGNORE = Symbol.for('__Spy_IGNORE__');

@@ -171,3 +162,3 @@ /**

}
var compared = [].concat((0, _toConsumableArray3.default)(alreadyComparedArray), [a]);
var compared = [].concat(_toConsumableArray(alreadyComparedArray), [a]);
var keys = mergeArrays(objectKeys(a), objectKeys(b));

@@ -174,0 +165,0 @@ for (var i = 0; i < keys.length; i++) {

{
"name": "spy4js",
"version": "1.4.0",
"version": "1.5.0",
"description": "Smart, compact and powerful spy test framework",

@@ -51,20 +51,47 @@ "jest": {

"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-jest": "^21.2.0",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.4",
"babel-jest": "^23.0.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-env": "^1.7.0",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"coveralls": "^3.0.0",
"eslint": "^4.10.0",
"eslint-config-prettier": "^2.6.0",
"eslint-plugin-flowtype": "^2.39.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jest": "^21.2.0",
"eslint-plugin-prettier": "^2.3.1",
"flow-bin": "^0.66.0",
"jest": "^21.2.1",
"prettier": "1.7.4"
"eslint": "^5.0.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-flowtype": "^2.49.3",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-prettier": "^2.6.1",
"eslint-plugin-react": "^7.9.1",
"flow-bin": "^0.74.0",
"jest": "^23.1.0",
"prettier": "1.7.4",
"react": "^16.4.1"
},
"babel": {
"presets": [
"env",
"flow",
"react"
],
"plugins": [
"transform-class-properties",
[
"transform-runtime",
{
"polyfill": false,
"helpers": false,
"regenerator": true
}
],
[
"transform-object-rest-spread",
{
"useBuiltIns": true
}
]
]
}
}

@@ -475,6 +475,2 @@ [![GitHub license][license-image]][license-url]

## Future
* Integrate automatic checks on older flow versions to determine the oldest compatible flow version.
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg

@@ -481,0 +477,0 @@ [license-url]: https://github.com/fdc-viktor-luft/form4react/blob/master/LICENSE

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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