Skip to content

Commit

Permalink
make print and pprint always call newline
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Aug 20, 2020
1 parent 29e6364 commit e0d5a0c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
* fix parsing R7RS hex literals in strings
* fix syntax-rules with `(a b ...)` that match single item
* fix swallowed undefined from `(cons 1 undefined)`
* fix identifiers in syntax-rules
* fix byte vectors
* make print and pprint always call newline

## 1.0.0-beta.3
## Bugfix
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Join the chat at https://gitter.im/jcubic/lips](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips)
[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/@jcubic/lips)
[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&7bf2d503c2978e7fd7cc5d4abcdd7beab9c32feb)](https://travis-ci.org/jcubic/lips)
[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&29e6364a2bdde7c67a1b0d9c62d8c705b1cbbadf)](https://travis-ci.org/jcubic/lips)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&2c48907438a7265935a7b21e6931008d)](https://coveralls.io/github/jcubic/lips?branch=devel)


Expand Down
22 changes: 14 additions & 8 deletions dist/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Copyright (c) 2014-present, Facebook, Inc.
* released under MIT license
*
* build: Thu, 20 Aug 2020 19:13:58 +0000
* build: Thu, 20 Aug 2020 19:59:43 +0000
*/
(function () {
'use strict';
Expand Down Expand Up @@ -7152,19 +7152,25 @@
} else {
this.get('display').call(this, arg);
}

this.get('newline').call(this);
}, "(pprint expression)\n\n Pretty print list expression, if called with non-pair it just call\n print function with passed argument."),
// ------------------------------------------------------------------
print: doc(function () {
var _this4 = this;

var display = this.get('display');
var newline = this.get('newline');

for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
args[_key13] = arguments[_key13];
}

this.get('stdout').write.apply(this, args.map(function (arg) {
return _this4.get('repr')(arg, LString.isString(arg));
}));
}, "(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code)"),
args.forEach(function (arg) {
display.call(_this4, arg);
newline.call(_this4);
});
}, "(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),
// ------------------------------------------------------------------
'format': doc(function format(str) {
for (var _len14 = arguments.length, args = new Array(_len14 > 1 ? _len14 - 1 : 0), _key14 = 1; _key14 < _len14; _key14++) {
Expand Down Expand Up @@ -10149,10 +10155,10 @@

var banner = function () {
// Rollup tree-shaking is removing the variable if it's normal string because
// obviously 'Thu, 20 Aug 2020 19:13:58 +0000' == '{{' + 'DATE}}'; can be removed
// obviously 'Thu, 20 Aug 2020 19:59:43 +0000' == '{{' + 'DATE}}'; can be removed
// but disablig Tree-shaking is adding lot of not used code so we use this
// hack instead
var date = LString('Thu, 20 Aug 2020 19:13:58 +0000').valueOf();
var date = LString('Thu, 20 Aug 2020 19:59:43 +0000').valueOf();

var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date);

Expand Down Expand Up @@ -10189,7 +10195,7 @@
var lips = {
version: 'DEV',
banner: banner,
date: 'Thu, 20 Aug 2020 19:13:58 +0000',
date: 'Thu, 20 Aug 2020 19:59:43 +0000',
exec: exec,
parse: parse,
tokenize: tokenize,
Expand Down
4 changes: 2 additions & 2 deletions dist/lips.min.js

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions src/lips.js
Original file line number Diff line number Diff line change
Expand Up @@ -4888,20 +4888,24 @@
} else {
this.get('display').call(this, arg);
}
this.get('newline').call(this);
}, `(pprint expression)
Pretty print list expression, if called with non-pair it just call
print function with passed argument.`),
// ------------------------------------------------------------------
print: doc(function(...args) {
this.get('stdout').write.apply(this, args.map((arg) => {
return this.get('repr')(arg, LString.isString(arg));
}));
const display = this.get('display');
const newline = this.get('newline');
args.forEach(arg => {
display.call(this, arg);
newline.call(this);
});
}, `(print . args)
Function convert each argument to string and print the result to
standard output (by default it's console but it can be defined
it user code)`),
it user code), the function call newline after printing each arg.`),
// ------------------------------------------------------------------
'format': doc(function format(str, ...args) {
typecheck('format', str, 'string');
Expand Down

0 comments on commit e0d5a0c

Please sign in to comment.