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

seroval

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seroval - npm Package Compare versions

Comparing version 0.4.0-alpha.0 to 0.4.0-alpha.1

26

dist/types/compat.d.ts

@@ -21,18 +21,16 @@ /**

export type Platform = keyof PlatformVersion;
interface VersionTable {
'aggregate-error': PlatformVersion;
'array-values': PlatformVersion;
'arrow-function': PlatformVersion;
'bigint': PlatformVersion;
'map': PlatformVersion;
'method-shorthand': PlatformVersion;
'object-assign': PlatformVersion;
'promise': PlatformVersion;
'set': PlatformVersion;
'symbol-iterator': PlatformVersion;
'typed-arrays': PlatformVersion;
export declare const enum Feature {
AggregateError = 0,
ArrayPrototypeValues = 1,
ArrowFunction = 2,
BigInt = 3,
Map = 4,
MethodShorthand = 5,
ObjectAssign = 6,
Promise = 7,
Set = 8,
SymbolIterator = 9,
TypedArray = 10
}
export type Feature = keyof VersionTable;
export type Target = [platform: Platform, version: Version];
export declare function parseTargets(targets: string | string[]): Set<Feature>;
export {};
{
"name": "seroval",
"type": "module",
"version": "0.4.0-alpha.0",
"version": "0.4.0-alpha.1",
"files": [

@@ -67,3 +67,3 @@ "dist",

},
"gitHead": "4b01f180e0a2548360ec618fe8b6cd4d36fccaff"
"gitHead": "53fa15bce900bc299752e07b106a1a84f4432f35"
}

@@ -0,1 +1,2 @@

/* eslint-disable guard-for-in */
/**

@@ -41,21 +42,23 @@ * References

interface VersionTable {
'aggregate-error': PlatformVersion;
'array-values': PlatformVersion;
'arrow-function': PlatformVersion;
'bigint': PlatformVersion;
'map': PlatformVersion;
'method-shorthand': PlatformVersion;
'object-assign': PlatformVersion;
'promise': PlatformVersion;
'set': PlatformVersion;
'symbol-iterator': PlatformVersion;
'typed-arrays': PlatformVersion;
export const enum Feature {
AggregateError,
ArrayPrototypeValues,
ArrowFunction,
BigInt,
Map,
MethodShorthand,
ObjectAssign,
Promise,
Set,
SymbolIterator,
TypedArray,
}
export type Feature = keyof VersionTable;
type VersionTable = {
[key in Feature]: PlatformVersion;
}
const VERSION_TABLE: VersionTable = {
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError#browser_compatibility
'aggregate-error': {
[Feature.AggregateError]: {
es: [2021, 0, 0],

@@ -73,3 +76,3 @@ chrome: [85, 0, 0],

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values#browser_compatibility
'array-values': {
[Feature.ArrayPrototypeValues]: {
es: [6, 0, 0],

@@ -87,3 +90,3 @@ chrome: [66, 0, 0],

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#browser_compatibility
'arrow-function': {
[Feature.ArrowFunction]: {
es: [6, 0, 0],

@@ -101,3 +104,3 @@ chrome: [45, 0, 0],

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#browser_compatibility
bigint: {
[Feature.BigInt]: {
es: [2020, 0, 0],

@@ -115,3 +118,3 @@ chrome: [67, 0, 0],

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#browser_compatibility
map: {
[Feature.Map]: {
es: [6, 0, 0],

@@ -129,3 +132,3 @@ chrome: [38, 0, 0],

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions#browser_compatibility
'method-shorthand': {
[Feature.MethodShorthand]: {
es: [6, 0, 0],

@@ -143,3 +146,3 @@ chrome: [39, 0, 0],

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#browser_compatibility
'object-assign': {
[Feature.ObjectAssign]: {
es: [6, 0, 0],

@@ -157,3 +160,3 @@ chrome: [45, 0, 0],

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#browser_compatibility
promise: {
[Feature.Promise]: {
es: [6, 0, 0],

@@ -171,3 +174,3 @@ chrome: [32, 0, 0],

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#browser_compatibility
set: {
[Feature.Set]: {
es: [6, 0, 0],

@@ -185,3 +188,3 @@ chrome: [38, 0, 0],

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator#browser_compatibility
'symbol-iterator': {
[Feature.SymbolIterator]: {
es: [6, 0, 0],

@@ -199,3 +202,3 @@ chrome: [43, 0, 0],

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#browser_compatibility
'typed-arrays': {
[Feature.TypedArray]: {
es: [6, 0, 0],

@@ -237,12 +240,2 @@ chrome: [7, 0, 0],

function isFeatureSupported(key: Feature, targets: Target[]) {
const base = VERSION_TABLE[key];
let flag = true;
for (const [platform, version] of targets) {
const baseVersion = base[platform];
flag = flag && !!baseVersion && (compareVersion(baseVersion, version) <= 0);
}
return flag;
}
export function parseTargets(targets: string | string[]): Set<Feature> {

@@ -253,5 +246,11 @@ const parsed = getTargetVersions(targets);

for (const key in VERSION_TABLE) {
if (isFeatureSupported(key as Feature, parsed)) {
flags.add(key as Feature);
const base = VERSION_TABLE[key as unknown as Feature];
let flag = true;
for (const [platform, version] of parsed) {
const baseVersion = base[platform];
flag = flag && !!baseVersion && (compareVersion(baseVersion, version) <= 0);
}
if (flag) {
flags.add(Number(key) as unknown as Feature);
}
}

@@ -258,0 +257,0 @@

/* eslint-disable no-await-in-loop */
import { isPrimitive } from './checks';
import { Feature } from './compat';
import {

@@ -56,3 +57,3 @@ createRef,

// Source is probably already assigned
if (ctx.features.has('arrow-function')) {
if (ctx.features.has(Feature.ArrowFunction)) {
params = ctx.vars.length > 1 || ctx.vars.length === 0

@@ -59,0 +60,0 @@ ? `(${params})`

@@ -484,35 +484,35 @@ /* eslint-disable guard-for-in */

if (constructorCheck<Int8Array>(current, Int8Array)) {
assert(ctx.features.has('typed-arrays'), 'Unsupported value type "Int8Array"');
assert(ctx.features.has(Feature.TypedArray), 'Unsupported value type "Int8Array"');
return [SerovalNodeType.TypedArray, ['Int8Array', current], id];
}
if (constructorCheck<Int16Array>(current, Int16Array)) {
assert(ctx.features.has('typed-arrays'), 'Unsupported value type "Int16Array"');
assert(ctx.features.has(Feature.TypedArray), 'Unsupported value type "Int16Array"');
return [SerovalNodeType.TypedArray, ['Int16Array', current], id];
}
if (constructorCheck<Int32Array>(current, Int32Array)) {
assert(ctx.features.has('typed-arrays'), 'Unsupported value type "Int32Array"');
assert(ctx.features.has(Feature.TypedArray), 'Unsupported value type "Int32Array"');
return [SerovalNodeType.TypedArray, ['Int32Array', current], id];
}
if (constructorCheck<Uint8Array>(current, Uint8Array)) {
assert(ctx.features.has('typed-arrays'), 'Unsupported value type "Uint8Array"');
assert(ctx.features.has(Feature.TypedArray), 'Unsupported value type "Uint8Array"');
return [SerovalNodeType.TypedArray, ['Uint8Array', current], id];
}
if (constructorCheck<Uint16Array>(current, Uint16Array)) {
assert(ctx.features.has('typed-arrays'), 'Unsupported value type "Uint16Array"');
assert(ctx.features.has(Feature.TypedArray), 'Unsupported value type "Uint16Array"');
return [SerovalNodeType.TypedArray, ['Uint16Array', current], id];
}
if (constructorCheck<Uint32Array>(current, Uint32Array)) {
assert(ctx.features.has('typed-arrays'), 'Unsupported value type "Uint32Array"');
assert(ctx.features.has(Feature.TypedArray), 'Unsupported value type "Uint32Array"');
return [SerovalNodeType.TypedArray, ['Uint32Array', current], id];
}
if (constructorCheck<Uint8ClampedArray>(current, Uint8ClampedArray)) {
assert(ctx.features.has('typed-arrays'), 'Unsupported value type "Uint8ClampedArray"');
assert(ctx.features.has(Feature.TypedArray), 'Unsupported value type "Uint8ClampedArray"');
return [SerovalNodeType.TypedArray, ['Uint8ClampedArray', current], id];
}
if (constructorCheck<Float32Array>(current, Float32Array)) {
assert(ctx.features.has('typed-arrays'), 'Unsupported value type "Float32Array"');
assert(ctx.features.has(Feature.TypedArray), 'Unsupported value type "Float32Array"');
return [SerovalNodeType.TypedArray, ['Float32Array', current], id];
}
if (constructorCheck<Float64Array>(current, Float64Array)) {
assert(ctx.features.has('typed-arrays'), 'Unsupported value type "Float64Array"');
assert(ctx.features.has(Feature.TypedArray), 'Unsupported value type "Float64Array"');
return [SerovalNodeType.TypedArray, ['Float64Array', current], id];

@@ -522,4 +522,4 @@ }

assert(
ctx.features.has('typed-arrays')
&& ctx.features.has('bigint'),
ctx.features.has(Feature.TypedArray)
&& ctx.features.has(Feature.BigInt),
'Unsupported value type "BigInt64Array"',

@@ -531,4 +531,4 @@ );

assert(
ctx.features.has('typed-arrays')
&& ctx.features.has('bigint'),
ctx.features.has(Feature.TypedArray)
&& ctx.features.has(Feature.BigInt),
'Unsupported value type "BigUint64Array"',

@@ -584,3 +584,3 @@ );

if (constructorCheck<Set<ServerValue>>(current, Set)) {
assert(ctx.features.has('set'), 'Unsupported type "Set"');
assert(ctx.features.has(Feature.Set), 'Unsupported type "Set"');
const nodes: SerovalNode[] = [];

@@ -603,3 +603,3 @@ const deferred: ServerValue[] = [];

if (constructorCheck<Map<ServerValue, ServerValue>>(current, Map)) {
assert(ctx.features.has('map'), 'Unsupported type "Map"');
assert(ctx.features.has(Feature.Map), 'Unsupported type "Map"');
const keyNodes: SerovalNode[] = [];

@@ -647,3 +647,3 @@ const valueNodes: SerovalNode[] = [];

}
if (current instanceof AggregateError && ctx.features.has('aggregate-error')) {
if (current instanceof AggregateError && ctx.features.has(Feature.AggregateError)) {
const options = getErrorOptions(current);

@@ -668,3 +668,3 @@ const optionsNode = options

if (isIterable(current)) {
assert(ctx.features.has('symbol-iterator'), 'Unsupported type "Iterable"');
assert(ctx.features.has(Feature.SymbolIterator), 'Unsupported type "Iterable"');
const options = getIterableOptions(current);

@@ -729,3 +729,3 @@ return [SerovalNodeType.Iterable, [

if (isPromise(current)) {
assert(ctx.features.has('promise'), 'Unsupported type "Promise"');
assert(ctx.features.has(Feature.Promise), 'Unsupported type "Promise"');
return current.then(async (value) => [

@@ -738,3 +738,3 @@ SerovalNodeType.Promise,

if (constructorCheck<Set<AsyncServerValue>>(current, Set)) {
assert(ctx.features.has('set'), 'Unsupported type "Set"');
assert(ctx.features.has(Feature.Set), 'Unsupported type "Set"');
const nodes: SerovalNode[] = [];

@@ -755,3 +755,3 @@ const deferred: AsyncServerValue[] = [];

if (constructorCheck<Map<AsyncServerValue, AsyncServerValue>>(current, Map)) {
assert(ctx.features.has('map'), 'Unsupported type "Map"');
assert(ctx.features.has(Feature.Map), 'Unsupported type "Map"');
const keyNodes: SerovalNode[] = [];

@@ -819,3 +819,3 @@ const valueNodes: SerovalNode[] = [];

if (isIterable(current)) {
assert(ctx.features.has('symbol-iterator'), 'Unsupported type "Iterable"');
assert(ctx.features.has(Feature.SymbolIterator), 'Unsupported type "Iterable"');
const options = getIterableOptions(current);

@@ -858,3 +858,3 @@ return [SerovalNodeType.Iterable, [

if (typeof value === 'bigint') {
assert(ctx.features.has('bigint'), 'Unsupported type "BigInt"');
assert(ctx.features.has(Feature.BigInt), 'Unsupported type "BigInt"');
return `${value}n`;

@@ -1104,3 +1104,3 @@ }

if (value[1]) {
if (ctx.features.has('object-assign')) {
if (ctx.features.has(Feature.ObjectAssign)) {
const options = serializeObject(id, value[1]);

@@ -1122,3 +1122,3 @@ serialized = `Object.assign(${serialized},${options})`;

if (value[2]) {
if (ctx.features.has('object-assign')) {
if (ctx.features.has(Feature.ObjectAssign)) {
const options = serializeObject(id, value[2]);

@@ -1143,3 +1143,3 @@ serialized = `Object.assign(${serialized},${options})`;

let serialized: string;
if (ctx.features.has('array-values')) {
if (ctx.features.has(Feature.ArrayPrototypeValues)) {
serialized = `${values}.values()`;

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

}
if (ctx.features.has('arrow-function')) {
if (ctx.features.has(Feature.ArrowFunction)) {
serialized = `{[Symbol.iterator]:()=>${serialized}}`;
} else if (ctx.features.has('method-shorthand')) {
} else if (ctx.features.has(Feature.MethodShorthand)) {
serialized = `{[Symbol.iterator](){return ${serialized}}}`;

@@ -1158,3 +1158,3 @@ } else {

if (value[0]) {
if (ctx.features.has('object-assign')) {
if (ctx.features.has(Feature.ObjectAssign)) {
const options = serializeObject(id, value[0]);

@@ -1175,3 +1175,3 @@ serialized = `Object.assign(${serialized},${options})`;

let serialized = 'Object.create(null)';
if (ctx.features.has('object-assign')) {
if (ctx.features.has(Feature.ObjectAssign)) {
const fields = serializeObject(id, value);

@@ -1178,0 +1178,0 @@ if (fields !== '{}') {

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

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

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