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

toSrc

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

toSrc - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

6

lib/toSrc.js

@@ -231,3 +231,7 @@ /**

if(typeof window !== 'undefined') { // IF TRUE: We're within a browser context
window.toSrc = toSrc;
if (window.toSrc === undefined) {
window.toSrc = toSrc;
} else {
console.log("Name collision: window.toSrc already exists...");
}
} else if(typeof module !== 'undefined'){ // IF TRUE: We're within a commonJS context (like node.js)

@@ -234,0 +238,0 @@ module.exports = toSrc;

6

package.json
{
"name": "toSrc",
"description": "Turns every JavaScript object or primitive into valid source code.",
"version": "0.1.0",
"homepage": "http://github.com/jhnns/toSrc",
"repository": "git://github.com/jhnns/toSrc.git",
"version": "0.1.1",
"homepage": "https://github.com/pandaa/toSrc",
"repository": "git://github.com/pandaa/toSrc.git",
"author": "Johannes Ewald <mail@johannesewald.de>",

@@ -8,0 +8,0 @@ "main": "./lib/toSrc.js",

@@ -10,2 +10,4 @@ toSrc

Works with node.js (tested) or in the browser (not tested)
Installation

@@ -17,8 +19,16 @@ ------------

-----
`require("toSrc")` returns a single function accepting these parameters:
* **Params**
1. **obj**: *The object to stringify. Can also be a primitive like `1` or `true`.*
2. **depth** (optional): *The depth to go. All nested structures like objects or arrays deeper than this will be undefined. Defaults to 1, meaning that every object or array will be undefined by default.*
1. **obj**: *The object to stringify. Can also be a primitive like `1` or `true`.*
2. **depth** (optional): *The depth to go. All nested structures like objects or arrays deeper than this will be undefined. Defaults to 1, meaning that every object or array will be undefined by default.*
* **In node.js**
`require("toSrc")(obj, depth);`
* **In the browser**
Just call `toSrc(obj, depth);`
Examples

@@ -28,2 +38,3 @@ -----

```javascript
var toSrc = require("toSrc");

@@ -82,2 +93,3 @@

// = '{"regEx": /regex/gi, "anotherObj": {"test": "test"}}'
```

@@ -94,2 +106,2 @@

Feel free to modify the code to meet your needs.
Feel free to modify the code to meet your needs.

@@ -109,5 +109,3 @@ //////////////////////////////////////////////////////////////////////////////////

);
assert.equal(toSrc(function() {
var test = "hello";
}), 'function () {\n var test = "hello";\n}');
assert.equal(toSrc(function() { var test = "hello"; }), 'function () { var test = "hello"; }');
assert.equal(toSrc([1, 2, "3"]), '[1, 2, "3"]');

@@ -114,0 +112,0 @@ assert.equal(toSrc({

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