Для сравнения была поставлена задача преобразовать входные данные вида:
var data = {
caption: "Cap",
people: [ 'John', 'Malkovich', 'Doe' ]
}
в строку Cap: John, Malkovich, Doe
String.prototype.toCamelCase = function() { | |
return this.substr(0, 1).toLowerCase() + this.substr(1).replace(/[\-_][a-z]/g, function($0){return $0.toUpperCase().replace(/[\_\-]/,'');}); | |
}; | |
String.prototype.toPascalCase = function() { | |
return this.substr(0, 1).toUpperCase() + this.substr(1).toCamelCase(); | |
}; | |
String.prototype.toUnderscore = function() { | |
return this.toCamelCase().replace(/[A-Z]/g, function($0){return "_"+$0.toLowerCase();}).replace(/^_/,''); | |
}; | |
String.prototype.toDash = function() { |
DROP TABLE IF EXISTS "forum_topic" 1404719138606 | |
DROP TABLE IF EXISTS "forum_comment" 1404719138610 | |
CREATE TABLE "forum_topic" ( | |
"id" SERIAL PRIMARY KEY, | |
"status" boolean , | |
"createdAt" timestamp with time zone , | |
"updatedAt" timestamp with time zone , | |
"title" varchar | |
) 1404719138624 | |
CREATE TABLE "forum_comment" ( |
Executing (default): SELECT "forum_topic".*, "Comments"."id" AS "Comments.id", "Comments"."status" AS "Comments.status", "Comments"."title" AS "Comments.title", "Comments"."topicId" AS "Comments.topicId", "Comments"."sys_created" AS "Comments.sys_created", "Comments"."sys_modified" AS "Comments.sys_modified", "Comments"."parent" AS "Comments.parent" FROM "forum_topic" LEFT OUTER JOIN "forum_comment" AS "Comments" ON "forum_topic"."id" = "Comments"."parent"; | |
events.js:72 | |
throw er; // Unhandled 'error' event | |
^ | |
error: relation "forum_topic" does not exist | |
at Connection.parseE (/home/qfox/web/megafon/selfcare-buddy/node_modules/pg/lib/connection.js:558:11) | |
at Connection.parseMessage (/home/qfox/web/megafon/selfcare-buddy/node_modules/pg/lib/connection.js:387:17) | |
at null.<anonymous> (/home/qfox/web/megafon/selfcare-buddy/node_modules/pg/lib/connection.js:92:20) | |
at Socket.EventEmitter.emit (events.js:95:17) |
Executing (default): INSERT INTO "forum_topic" ("title","id","createdAt","updatedAt") VALUES ('a',DEFAULT,'2014-07-11 08:06:10.130 +00:00','2014-07-11 08:06:10.130 +00:00'),('b',DEFAULT,'2014-07-11 08:06:10.130 +00:00','2014-07-11 08:06:10.130 +00:00'),('c',DEFAULT,'2014-07-11 08:06:10.130 +00:00','2014-07-11 08:06:10.130 +00:00'),('d',DEFAULT,'2014-07-11 08:06:10.130 +00:00','2014-07-11 08:06:10.130 +00:00') RETURNING *; | |
Executing (default): SELECT * FROM "forum_topic"; | |
[ '{"id":1,"title":"a","createdAt":"2014-07-11T08:06:10.130Z","updatedAt":"2014-07-11T08:06:10.130Z"}', | |
'{"id":2,"title":"b","createdAt":"2014-07-11T08:06:10.130Z","updatedAt":"2014-07-11T08:06:10.130Z"}', | |
'{"id":3,"title":"c","createdAt":"2014-07-11T08:06:10.130Z","updatedAt":"2014-07-11T08:06:10.130Z"}', | |
'{"id":4,"title":"d","createdAt":"2014-07-11T08:06:10.130Z","updatedAt":"2014-07-11T08:06:10.130Z"}' ] | |
Executing (default): SELECT * FROM "forum_topic" WHERE title <> 'a'; | |
[ '{"id":2,"title":"b","createdAt":"2014-07-11T08:06:10.130Z", |
if ($postfix) { | |
set $postfix "-$postfix"; | |
} | |
if ($pages_path = "") { | |
set $pages_path "desktop.bundles"; | |
} | |
set $pages_path "$pages_path$postfix"; |
sed -r -e 's/module.exports.*$/<?php\nreturn function ($bh) {/' \ | |
-e 's/bh\.match/\$bh->match/' \ | |
-e 's/function\(ctx\)/function($ctx)/' \ | |
-e 's/function\(ctx, json\)/function($ctx, $json)/' \ | |
-e 's/ctx\./$ctx->/g' \ | |
-e 's/(\s*)ctx$/\1$ctx/' \ | |
-e 's/json\./$json->/g' \ | |
-e 's/attrs\./$attrs->/g' \ | |
-e 's/\.(\w+)/->\1/g' \ | |
-e 's/(\w+) : /'\''\1'\'' => /g' |
var U = require('express-bem/lib/util'); | |
var dropRequireCache = require('enb/lib/fs/drop-require-cache'); | |
module.exports = dynjson; | |
dynjson.extension = '.dynjson.js'; | |
/** | |
* dynjson engine for express-bem | |
* @param {string} name - bundle name |
/** | |
* Scope creator | |
* @return {} | |
*/ | |
function create () { | |
var undef; | |
/** | |
* BEM entity object | |
* @constructor |
({ | |
block : 'page', | |
title : 'elem-inst-test', | |
styles : [{ elem : 'css', url : 'elem-inst-test.min.css' }], | |
scripts : [{ elem : 'js', url : 'elem-inst-test.min.js' }], | |
content : [ | |
{ | |
block : 'elem-inst-test', | |
js : true, | |
mods : { mod : true }, |