New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rapunzel

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rapunzel

A lightweight module to simplify the process of generating pretty strings of code

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

rapunzel [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]

This lightweight module simplifies the process of generating code strings

Install

$ npm install --save rapunzel

Usage

var rapunzel = require('rapunzel');

var h_obj = {
	"example":
	{
		"of": "stringifying a simple object",
		"that": "only has objects and strings",
	}
};

var stringify_obj = function(add, h_part) {
	if('string' === typeof h_part) {
		add("'"+h_part.replace(/'/g, "\\'")+"'", true);
	}
	else {
		this.open('{', ',', true);
		for(var s_property in h_part) {
			add(s_property+': ');
			stringify_obj.apply(this, [add, h_part[s_property]]);
		}
		this.close('}');
	}
};

var k_builder = rapunzel({
	preamble: function(add) {
		add('// this is the beginning');
	},
	body: function(add) {
		stringify_obj.apply(this, [add, h_obj]);
	},
	closing: function(add) {
		add('// this is the end');
	},
});

k_builder.produce({
	indent: '\t',
});

yields:

// this is the beginning
{
	example: {
		of: 'stringifying a simple object',
		that: 'only has objects and strings',
	},
}
// this is the end

License

ISC © Blake Regalia

Keywords

FAQs

Package last updated on 05 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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