Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created March 9, 2012 17:11
Show Gist options
  • Save isaacs/2007585 to your computer and use it in GitHub Desktop.
Save isaacs/2007585 to your computer and use it in GitHub Desktop.
// minimal vertical spread
w = { foo : "bar"
, foo2 : { hello : "world" }
, foo3 : { wow : "this", is : "really", getting : "long" } }
// some more vertical spread
x = { foo : "bar"
, foo2 : { hello : "world" }
, foo3 : { wow : "this"
, is : "really"
, getting : "long" } }
// a bit more
y = { foo : "bar"
, foo2 : { hello : "world" }
, foo3 :
{ wow : "this"
, is : "really"
, getting : "long" } }
// maximally vertically spread
z = { foo : "bar"
, foo2 :
{ hello : "world" }
, foo3 :
{ wow : "this"
, is : "really"
, getting : "long"
}
}
// in the case of a longer var name,
// wrap and indent to the next line is fine, too
// obviously, THIS var name is much too long,
// but it's not uncommon to start an object far to
// the right, and in those cases, a \n and indent
// makes it easier to look at.
aLongVarNameThatLeavesLittleRoomAfterIt =
{ foo : "bar"
, foo2 : { hello : "world" }
, foo3 : { wow : "this", is : "really", getting : "long" } }
// It's sometimes more convenient to omit the first
// indent. I don't do this in npm, but do in some
// other projects. Just be consistent.
bLongVarNameThatLeavesLittleRoomAfterIt =
{ foo : "bar"
, foo2 : { hello : "world" }
, foo3 : { wow : "this", is : "really", getting : "long" } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment