Giter Club home page Giter Club logo

formatio's Introduction

formatio - DEPRECATED


This package has been deprecated and will receive no further maintenance.

If you need this package, please fork it and maintain it yourself.


Build status codecov Contributor Covenant

The cheesy object formatter

Pretty formatting of arbitrary JavaScript values. Currently only supports ascii formatting, suitable for command-line utilities. Like JSON.stringify, it formats objects recursively, but unlike JSON.stringify, it can handle regular expressions, functions, circular objects and more.

formatio is a general-purpose library. It works in browsers (including old and rowdy ones, like IE6) and Node. It will define itself as an AMD module if you want it to (i.e. if there's a define function available).

Installation

npm install @sinonjs/formatio

Documentation

https://sinonjs.github.io/formatio/

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]

Licence

formatio was released under BSD-3

formatio's People

Contributors

augustl avatar brandone avatar cjohansen avatar dependabot-preview[bot] avatar dependabot[bot] avatar dominykas avatar dwittner avatar edwardbetts avatar fatso83 avatar geddski avatar jodal avatar mantoni avatar mgred avatar mroderick avatar mshaaban0 avatar phaiax avatar teknynja avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

formatio's Issues

Update sinonjs/samsam in package.json

We understand you have a problem and are in a hurry, but please provide us with some info to make it much more likely for your issue to be understood, worked on and resolved quickly.

  • library version : 3.2.1
  • Environment :
  • Example URL :
  • Other libraries you are using: sinon

What did you expect to happen?

What actually happens

We need the updated version of sinonjs/samsam (3.3.3) as a dependency of formatio because of a need to update lodash version that it uses (sinonjs/samsam#72)

How to reproduce

Describe with code how to reproduce the faulty behaviour,
or link to code on JSBin or similar

Prepare project for a new life as a Sinon.JS project

Code

  • Configure mocha and referee
  • Port tests to mocha
  • Use nyc for test coverage
  • Add .editorconfig
  • ESLint
    • Use eslint-config-sinon
    • Use eslint-plugin-ie11
    • Use eslint-plugin-mocha
    • Use lint-staged and husky for pre-commit hook

Third party services

  • Run tests in node LTS versions (4, 6, 8) on Travis
  • Push coverage report to coveralls
  • Configure bithound.io for repository

Repository

  • Port documentation to MkDocs and publish to GitHub Pages
  • Add CONTRIBUTING.md
  • Add pull request template
  • Add new issue template
  • Add .github/stale.yml and create pinned and stale labels
  • Protect master branch from force pushes, including for administrators

NPM

  • Add .npmignore / files section and filter out files that package consumers would not want
  • Publish module under @sinonjs scope with a new MAJOR version
  • Deprecate old package on npm (who can do this?)

ascii.element throws in environments where the DOM is not fully implemented

This is not a bug report as much as it is to document.

In some Node environments the DOM is not fully implemented. In my case using basicHTML. In this senario the ascii.element function assumes that the element being passed in as the argument fully implements NamedNodeMap and calls the item method.

  • library version : 3.1.0
  • Environment : Node
  • Other libraries you are using: Sinon, Referee, referee-plugin-dom

What did you expect to happen?
That formatio would check that item was a method on the attrs object before calling it.

What actually happens
attrs.items is called without checking and an error is thrown

How to reproduce

  • Clone https://github.com/sinonjs/referee-plugin-dom
  • npm install && npm install basichtml --save-dev
  • Edit demo/index.test.js
    Replace require("jsdom-global")(); with require('basichtml').init();
  • Execute npm run demo
  • Observe that an error is thrown
Stacktrace
TypeError: attrs.item is not a function
    at Function.ascii.element (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/formatio/lib/formatio.js:186:22)
    at ascii (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/formatio/lib/formatio.js:78:50)
    at Formatio.ascii (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/formatio/lib/formatio.js:227:16)
    at format (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/referee/lib/format.js:18:28)
    at /Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/referee/lib/interpolate-properties.js:21:23
    at Array.reduce (<anonymous>)
    at interpolateProperties (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/referee/lib/interpolate-properties.js:15:12)
    at Object.fail (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/referee/lib/define-assertion.js:32:27)
    at assertion (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/referee/lib/define-assertion.js:68:17)
    at Function.referee.(anonymous function).(anonymous function) [as tagName] (/Users/david/Documents/work/referee-plugin-dom/node_modules/@sinonjs/referee/lib/define-assertion.js:93:26)
    at Context.<anonymous> (/Users/david/Documents/work/referee-plugin-dom/demo/basic-html.test.js:37:32)
    at callFn (/Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runnable.js:387:21)
    at Test.Runnable.run (/Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runnable.js:379:7)
    at Runner.runTest (/Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runner.js:525:10)
    at /Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runner.js:643:12
    at next (/Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runner.js:437:14)
    at /Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runner.js:447:7
    at next (/Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runner.js:362:14)
    at Immediate.<anonymous> (/Users/david/Documents/work/referee-plugin-dom/node_modules/mocha/lib/runner.js:415:5)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)
    at processImmediate [as _immediateCallback] (timers.js:729:5)

formatio package not available.

Hi,

I am trying to install Sinon and it is throwing an error.
npm ERR! node v6.10.2
npm ERR! npm v3.10.10
npm ERR! code E404
npm ERR! 404 no such package available : @sinonjs/formatio
npm ERR! 404
npm ERR! 404 '@sinonjs/formatio' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'nise'

I tried installing from 4.3.0 to 3.2.1 nothing works. This is happening only from yesterday.

Thanks,
Udaykiran

toString might crash

  • library version : @sinonjs/formatio@^3.1.0
  • Environment : node/ sinon/mocha

Calling sinon.assert.calledWith fails, if the stub was called with an object having a toString method which throws.

How to reproduce

it('shall reproduce formatio bug', function () {
	const poison = {
		toString: () => {
			throw new Error("Boom");
		}
	};

	const myStub = sinon.stub();
	myStub(poison);

	sinon.assert.calledWith(myStub, "42");
});

Expectation is to see a sinon error message like "expected stub to be called with..." instead of a formatio error.

I think a try/catch and swallow the error should be sufficient.

Non-backward-compatible change of constructorName

  • library version : 3.1.1
  • Environment : node 10.15.1

What did you expect to happen?

formatio.constructorName(Object.create(null, {})) returns an empty string.

What actually happens

It throws an error: TypeError: Cannot read property 'displayName' of undefined

How to reproduce

const formatio = require('@sinonjs/formatio');
console.log(formatio.constructorName(Object.create(null, {})));

At 3.1.0, constructorName returned an empty string if an argument didn't have a constructor, but now it throws an error.

We faced this issue when we used sinon and should-sinon. Here is a snippet to reproduce the original issue we had.

const sinon = require('sinon');
require('should-sinon');

const stub = sinon.stub().returns();
const o = Object.create(null, {});
stub(o);
stub.should.be.calledWithExactly(o);

With 3.1.0, this snippet runs without errors, but with 3.1.1 it throws an error: TypeError: Cannot read property 'displayName' of undefined.

ascii(0n) throws, but other BigInts work fine

  • library version : 3.2.1
  • Environment : Node.js 12.6.0

What did you expect to happen?

I expected this to work with BigInts just fine. It seems to be the case for most BigInts, except 0n.

What actually happens

It throws TypeError: Cannot mix BigInt and other types, use explicit conversions.

How to reproduce

formatio.ascii(0n)

produces this error and stacktrace:

> formatio.ascii(0n)
Thrown:
TypeError: Cannot mix BigInt and other types, use explicit conversions
    at ascii (.../node_modules/@sinonjs/formatio/lib/formatio.js:77:37)
    at Object.ascii (.../node_modules/@sinonjs/formatio/lib/formatio.js:227:16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.