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

language

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

language - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

15

index.js

@@ -13,4 +13,19 @@ function fieldsInObject(o) {

function bind(fields, object) {
for (var n = 0; n < fields.length; n++) {
(function (n) {
var field = [fields[n]];
var value = object[field];
if (typeof value === 'function') {
object[field] = function () {
return value.apply(object, arguments);
};
}
})(n);
}
}
module.exports = function (dsl) {
var terms = fieldsInObject(dsl);
bind(terms, dsl);
var callArgs = terms.map(function (p) { return 'dsl.' + p; }).join(',');

@@ -17,0 +32,0 @@

2

package.json
{
"name": "language",
"version": "0.1.2",
"version": "0.2.0",
"description": "DSLs for the washed masses",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,25 +9,23 @@ # Language

Because magic scope!
Because magic scope! and because no globals!
var language = require('language');
var position = {x: 0, y: 0};
var robot = language({
position: position,
position: {x: 0, y: 0},
moveLeft: function() {
position.x--;
this.position.x--;
},
moveRight: function() {
position.x++;
this.position.x++;
},
moveUp: function() {
position.y--;
this.position.y--;
},
moveDown: function() {
position.y++;
this.position.y++;
},

@@ -34,0 +32,0 @@ });

var language = require('./');
var position = {x: 0, y: 0};
var robot = language({
position: position,
position: {x: 0, y: 0},
moveLeft: function() {
position.x--;
this.position.x--;
},
moveRight: function() {
position.x++;
this.position.x++;
},
moveUp: function() {
position.y--;
this.position.y--;
},
moveDown: function() {
position.y++;
this.position.y++;
},

@@ -23,0 +21,0 @@ });

@@ -28,2 +28,26 @@ var language = require('..');

});
it('can call methods on language object, with this', function () {
var simple = language({
n: 1,
inc: function (amount) {
if (typeof amount === 'undefined') {
amount = 1;
}
this.n += amount;
},
val: function () {
return this.n;
}
});
var f = simple(function () {
inc();
inc(2);
return val();
});
f.should.equal(4);
});
});

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