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

sweet-algebras

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sweet-algebras - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

test/_compile.js

13

package.json
{
"name": "sweet-algebras",
"version": "0.0.3",
"version": "0.0.4",
"description": "A implementation of emcascript-algebras with macros",
"main": "src/index.js",
"scripts": {
"test": "echo \"no tests yet\"; exit 1"
"test": "ava"
},

@@ -13,7 +13,14 @@ "author": "Tim Disney",

"@sweet-js/cli": "^3.0.7",
"@sweet-js/core": "^3.0.7"
"@sweet-js/core": "^3.0.7",
"ava": "^0.19.1",
"tmp": "^0.0.31"
},
"dependencies": {
"@sweet-js/helpers": "^3.0.0"
},
"ava": {
"files": [
"test/*"
]
}
}
'lang sweet.js';
import { matchImplements, matchExtendsClause, matchAny, matchInterfaceItems, matchIdentifier, matchBraces } from './match-util' for syntax;
import { unwrap, fromStringLiteral } from '@sweet-js/helpers' for syntax;
/*
TODO:
- what do we do about extending interfaces that conflict?
- do we actually need to put the symbols on the prototype?
*/
export syntax interface = ctx => {

@@ -11,11 +18,32 @@ let name = matchIdentifier(ctx);

let fields = items.reduce((acc, item) => {
if (item.type === 'field') {
return acc.concat(#`${item.name}: { value: Symbol(), writable: false, configurable: false, enumerable: true },`);
if (item.type === 'field' || item.type === 'static') {
return acc.concat(#`${item.name}: { value: Symbol(),
writable: false, configurable: false, enumerable: true },`);
} else {
return acc.concat(#`${item.name}: { value: function ${item.parens} ${item.body}, writable: false, configurable: false, enumerable: true },`);
return acc.concat(#`${item.name}: { value: function ${item.parens} ${item.body},
writable: false, configurable: false, enumerable: true },`);
}
}, #``);
let staticsArr = items.reduce((acc, item) => {
if (item.type === 'static') {
return acc.concat(#`${fromStringLiteral(item.name, unwrap(item.name).value)}, `)
}
return acc;
}, #``);
let statics = #`_statics: {
value: [${staticsArr}],
configurable: false, writable: false, enumerable: false
},`;
let mixin = #`_mixin: { value: function(klass) {
Object.assign(klass, this);
for (let s in this) {
if (typeof this[s] === 'symbol' && this._statics.includes(s)) {
klass[this[s]] = void 0;
} else if (typeof this[s] === 'symbol') {
klass.prototype[this[s]] = void 0;
} else {
klass.prototype[s] = this[s];
}
}
}, configurable: false, writable: false, enumerable: false},`;

@@ -30,2 +58,3 @@

${mixin}
${statics}
});

@@ -32,0 +61,0 @@ ${ext}

@@ -78,6 +78,10 @@ 'lang sweet.js';

let name = matchIdentifierOrKeyword(ctx);
let type = 'field';
if (unwrap(name).value === 'static') {
type = 'static';
name = matchIdentifierOrKeyword(ctx);
}
matchPunctuator(ctx, ';');
return {
type: 'field',
name
type, name
};

@@ -84,0 +88,0 @@ }

@@ -25,2 +25,6 @@ 'lang sweet.js';

let j = new Just(1);
console.log(Object.getOwnPropertySymbols());
new Just(1)[Functor.map](console.log);

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