sweet-algebras
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
143076
9
306
2
4
2
1