Skip to content

Commit

Permalink
merge with devel
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Apr 23, 2019
2 parents d05ff7d + b98cb72 commit a4db275
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 40 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.3
### Bug fixes
* fix print that get stdout from global env not from user one + better babel fix added in 0.10.1

## 0.10.2
### Bug fixes
* fix version number in source code
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## LIPS is Pretty Simple

[![npm](https://img.shields.io/badge/npm-0.10.2-blue.svg)](https://www.npmjs.com/package/@jcubic/lips)
[![travis](https://travis-ci.org/jcubic/jquery.terminal.svg?branch=master&dbc5022acc1943aee088a1c22f809abea1406e54)](https://travis-ci.org/jcubic/jquery.terminal)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=master&4b1fff165354dc9dcd90095d14379037)](https://coveralls.io/github/jcubic/lips?branch=master)
[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/@jcubic/lips)
[![travis](https://travis-ci.org/jcubic/jquery.terminal.svg?branch=devel&ebe5b27f4c4a5bd291ad1ca0c9a7c1201a18404a)](https://travis-ci.org/jcubic/jquery.terminal)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&4b1fff165354dc9dcd90095d14379037)](https://coveralls.io/github/jcubic/lips?branch=devel)


LIPS is very simple Lisp, similar to Scheme written in JavaScript.
Expand Down
42 changes: 25 additions & 17 deletions dist/lips.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**@license
* LIPS is Pretty Simple - simple scheme like lisp in JavaScript - v. 0.10.2
* LIPS is Pretty Simple - simple scheme like lisp in JavaScript - v. DEV
*
* Copyright (c) 2018-2019 Jakub T. Jankiewicz <https://jcubic.pl/me>
* Released under the MIT license
Expand All @@ -21,7 +21,7 @@
* http://javascript.nwbox.com/ContentLoaded/
* http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE
*
* build: Mon, 22 Apr 2019 20:50:49 +0000
* build: Tue, 23 Apr 2019 07:56:30 +0000
*/
(function () {
'use strict';
Expand Down Expand Up @@ -2272,6 +2272,15 @@ function _typeof(obj) {
} // ----------------------------------------------------------------------


function unbind(obj) {
if (typeof obj === 'function' && obj.__bind) {
return obj.__bind.fn;
}

return obj;
} // ----------------------------------------------------------------------


function setFnLength(fn, length) {
try {
Object.defineProperty(fn, 'length', {
Expand Down Expand Up @@ -2836,7 +2845,10 @@ function _typeof(obj) {
}; // ----------------------------------------------------------------------


Environment.prototype.get = function (symbol) {
Environment.prototype.get = function (symbol, weak, context) {
// we keep original environment as context for bind
// so print will get user stdout
context = context || this;
var value;
var defined = false;

Expand All @@ -2858,14 +2870,18 @@ function _typeof(obj) {
}

if (typeof value === 'function') {
return weakBind(value, this);
if (weak) {
return weakBind(value, context);
}

return value.bind(context);
}

return value;
}

if (this.parent instanceof Environment) {
return this.parent.get(symbol);
return this.parent.get(symbol, weak, context);
} else {
var name;

Expand Down Expand Up @@ -3820,13 +3836,7 @@ function _typeof(obj) {
'get': get,
'.': get,
// ------------------------------------------------------------------
'unbind': doc(function (obj) {
if (typeof obj === 'function' && obj.__bind) {
return obj.__bind.fn;
}

return obj;
}, "(unbind fn)\n Function remove bidning from function so you can get props from it."),
'unbind': doc(unbind, "(unbind fn)\n\n Function remove bidning from function so you can get props from it."),
// ------------------------------------------------------------------
type: doc(type, "(type object)\n\n Function return type of an object as string."),
// ------------------------------------------------------------------
Expand Down Expand Up @@ -3980,8 +3990,6 @@ function _typeof(obj) {
}, "(Find fn list)\n\n Higher order Function find first value for which function\n return true."),
// ------------------------------------------------------------------
'for-each': doc(function (fn) {
var _this$get2;

typecheck('for-each', fn, 'function'); // we need to use call(this because babel transpile this code into:
// var ret = map.apply(void 0, [fn].concat(args));
// it don't work with weakBind
Expand All @@ -3990,7 +3998,7 @@ function _typeof(obj) {
args[_key18 - 1] = arguments[_key18];
}

var ret = (_this$get2 = this.get('map')).call.apply(_this$get2, [this, fn].concat(args));
var ret = this.get('map').apply(void 0, [fn].concat(args));

if (isPromise(ret)) {
return ret.then(function () {});
Expand Down Expand Up @@ -4633,7 +4641,7 @@ function _typeof(obj) {
}

if (first instanceof _Symbol) {
value = env.get(first);
value = env.get(first, true);

if (value instanceof Macro) {
return evaluate_macro(value, rest, eval_args);
Expand Down Expand Up @@ -4855,7 +4863,7 @@ function _typeof(obj) {


return {
version: '0.10.2',
version: 'DEV',
exec: exec,
parse: parse,
tokenize: tokenize,
Expand Down
6 changes: 3 additions & 3 deletions dist/lips.min.js

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions examples/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ function terminal({selector, lips, dynamic = false, name = 'terminal'}) {
var position;
var timer;
var help = lips.env.get('help');
function doc(fn, doc) {
fn.__doc__ = doc;
return fn;
}
// -------------------------------------------------------------------------
var env = lips.env.inherit(name, {
stdout: {
write: function() {
Expand All @@ -19,18 +24,22 @@ function terminal({selector, lips, dynamic = false, name = 'terminal'}) {
});
}
},
// ---------------------------------------------------------------------
stdin: {
read: function() {
return term.read('');
}
},
help: function(fn) {
term.echo(help(fn));
},
error: function(message) {
// ---------------------------------------------------------------------
help: doc(function(fn) {
term.echo(help(fn), { formatters: false });
}, lips.env.env.help.__doc__),
// ---------------------------------------------------------------------
error: doc(function(message) {
term.error(message);
}
}, lips.env.env.error.__doc__)
});
// -------------------------------------------------------------------------
var term = jQuery(selector).terminal(function(code, term) {
lips.exec(code, env, dynamic).then(function(ret) {
ret.forEach(function(ret) {
Expand Down
35 changes: 23 additions & 12 deletions src/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,13 @@
return setFnLength(binded, binded.__bind.fn.length);
}
// ----------------------------------------------------------------------
function unbind(obj) {
if (typeof obj === 'function' && obj.__bind) {
return obj.__bind.fn;
}
return obj;
}
// ----------------------------------------------------------------------
function setFnLength(fn, length) {
try {
Object.defineProperty(fn, 'length', {
Expand Down Expand Up @@ -1584,7 +1591,10 @@
return new Environment(obj || {}, this, name);
};
// ----------------------------------------------------------------------
Environment.prototype.get = function(symbol) {
Environment.prototype.get = function(symbol, weak, context) {
// we keep original environment as context for bind
// so print will get user stdout
context = context || this;
var value;
var defined = false;
if (symbol instanceof Symbol) {
Expand All @@ -1603,12 +1613,15 @@
return LNumber(value);
}
if (typeof value === 'function') {
return weakBind(value, this);
if (weak) {
return weakBind(value, context);
}
return value.bind(context);
}
return value;
}
if (this.parent instanceof Environment) {
return this.parent.get(symbol);
return this.parent.get(symbol, weak, context);
} else {
var name;
if (symbol instanceof Symbol) {
Expand Down Expand Up @@ -2528,13 +2541,11 @@
'get': get,
'.': get,
// ------------------------------------------------------------------
'unbind': doc(function(obj) {
if (typeof obj === 'function' && obj.__bind) {
return obj.__bind.fn;
}
return obj;
}, `(unbind fn)
Function remove bidning from function so you can get props from it.`),
'unbind': doc(
unbind,
`(unbind fn)
Function remove bidning from function so you can get props from it.`),
// ------------------------------------------------------------------
type: doc(
type,
Expand Down Expand Up @@ -2724,7 +2735,7 @@
// we need to use call(this because babel transpile this code into:
// var ret = map.apply(void 0, [fn].concat(args));
// it don't work with weakBind
var ret = this.get('map').call(this, fn, ...args);
var ret = this.get('map')(fn, ...args);
if (isPromise(ret)) {
return ret.then(() => {});
}
Expand Down Expand Up @@ -3346,7 +3357,7 @@
}
}
if (first instanceof Symbol) {
value = env.get(first);
value = env.get(first, true);
if (value instanceof Macro) {
return evaluate_macro(value, rest, eval_args);
} else if (typeof value !== 'function') {
Expand Down

0 comments on commit a4db275

Please sign in to comment.