id stringlengths 34 124 | type stringclasses 4
values | prompt stringlengths 0 4.95k | response stringlengths 21 4.89k | source_lang stringclasses 3
values | target_lang stringclasses 2
values | repo stringclasses 75
values | path stringlengths 10 88 | license stringclasses 1
value | commit stringlengths 40 40 | stars int64 431 18.7k | source_url stringlengths 86 176 | line_start int64 1 214 | line_end int64 3 253 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
discolabs/cartjs:src/utils.coffee:3:raw_corpus | raw_corpus | # Fetch the appropriate format.
if (window.Currency?.moneyFormats?) and (currency of window.Currency.moneyFormats)
format = window.Currency.moneyFormats[currency][formatName]
# Render the formatted amount using the Shopify formatter if available, else just the value.
if window.Shopify?.formatMone... | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | de7b256420fe4fa5a348dfe03716d305cf2d5f0e | 493 | https://github.com/discolabs/cartjs/blob/de7b256420fe4fa5a348dfe03716d305cf2d5f0e/src/utils.coffee | 88 | 99 | ||
discolabs/cartjs:src/utils.coffee:3:completion | completion | # Fetch the appropriate format.
if (window.Currency?.moneyFormats?) and (currency of window.Currency.moneyFormats)
format = window.Currency.moneyFormats[currency][formatName]
# Render the formatted amount using the Shopify formatter if available, else just the value.
if window.Shopify?.formatMone... | # Return a resized image URL using Shopify's getSizedImageUrl if available.
#
# If it's not available, just return the original URL.
getSizedImageUrl: (src, size) ->
if window.Shopify?.Image?.getSizedImageUrl? then Shopify.Image.getSizedImageUrl(src, size) else src | CoffeeScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | de7b256420fe4fa5a348dfe03716d305cf2d5f0e | 493 | https://github.com/discolabs/cartjs/blob/de7b256420fe4fa5a348dfe03716d305cf2d5f0e/src/utils.coffee | 88 | 99 |
discolabs/cartjs:src/utils.coffee:2:raw_corpus | raw_corpus | # Extend a source object with the properties of another object.
#
# Can be used to shallow copy an object like so:
# copy = extend({}, original)
extend: (object, properties) ->
for key, val of properties
object[key] = val
object
# Clone a source object (deep copy).
clone: (object) ->
if... | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | fed202eef84f6a39f131f42d3dbaf573bafe224b | 493 | https://github.com/discolabs/cartjs/blob/fed202eef84f6a39f131f42d3dbaf573bafe224b/src/utils.coffee | 48 | 87 | ||
discolabs/cartjs:src/utils.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# Extend a source object with the properties of another object.
#
# Can be used to shallow copy an object like so:
# copy = extend({}, original)
extend: (object, properties) ->
for key, val of properties
object[key] = val
object
# Clone... | // Extend a source object with the properties of another object.
// Can be used to shallow copy an object like so:
// copy = extend({}, original)
({
extend: function(object, properties) {
var key, val;
for (key in properties) {
val = properties[key];
object[key] = val;
}
return object;
... | CoffeeScript | JavaScript | discolabs/cartjs | src/utils.coffee | MIT | fed202eef84f6a39f131f42d3dbaf573bafe224b | 493 | https://github.com/discolabs/cartjs/blob/fed202eef84f6a39f131f42d3dbaf573bafe224b/src/utils.coffee | 48 | 87 |
discolabs/cartjs:src/utils.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// Extend a source object with the properties of another object.
// Can be used to shallow copy an object like so:
// copy = extend({}, original)
({
extend: function(object, properties) {
var key, val;
for (key in properties) {
val = properties[k... | # Extend a source object with the properties of another object.
#
# Can be used to shallow copy an object like so:
# copy = extend({}, original)
extend: (object, properties) ->
for key, val of properties
object[key] = val
object
# Clone a source object (deep copy).
clone: (object) ->
if... | JavaScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | fed202eef84f6a39f131f42d3dbaf573bafe224b | 493 | https://github.com/discolabs/cartjs/blob/fed202eef84f6a39f131f42d3dbaf573bafe224b/src/utils.coffee | 48 | 87 |
discolabs/cartjs:src/utils.coffee:2:completion | completion | # Extend a source object with the properties of another object.
#
# Can be used to shallow copy an object like so:
# copy = extend({}, original)
extend: (object, properties) ->
for key, val of properties
object[key] = val
object
# Clone a source object (deep copy).
clone: (object) ->
if... | {}.toString.call(value) is '[object Array]'
# Ensure that the given value is returned as an array, either with entries intact or as a blank value.
ensureArray: (value) ->
if CartJS.Utils.isArray(value)
return value
if value? then [value] else []
# Format a monetary amount using Shopify's formatMon... | CoffeeScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | fed202eef84f6a39f131f42d3dbaf573bafe224b | 493 | https://github.com/discolabs/cartjs/blob/fed202eef84f6a39f131f42d3dbaf573bafe224b/src/utils.coffee | 48 | 87 |
discolabs/cartjs:src/utils.coffee:3:raw_corpus | raw_corpus | # Render the formatted amount using the Shopify formatter if available, else just the value.
if window.Shopify?.formatMoney? then Shopify.formatMoney(value, format) else value
# Return a resized image URL using Shopify's getSizedImageUrl if available.
#
# If it's not available, just return the original URL.
... | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | fed202eef84f6a39f131f42d3dbaf573bafe224b | 493 | https://github.com/discolabs/cartjs/blob/fed202eef84f6a39f131f42d3dbaf573bafe224b/src/utils.coffee | 89 | 96 | ||
discolabs/cartjs:src/utils.coffee:3:completion | completion | # Render the formatted amount using the Shopify formatter if available, else just the value.
if window.Shopify?.formatMoney? then Shopify.formatMoney(value, format) else value
# Return a resized image URL using Shopify's getSizedImageUrl if available. | #
# If it's not available, just return the original URL.
getSizedImageUrl: (src, size) ->
if window.Shopify?.Image?.getSizedImageUrl? then Shopify.Image.getSizedImageUrl(src, size) else src | CoffeeScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | fed202eef84f6a39f131f42d3dbaf573bafe224b | 493 | https://github.com/discolabs/cartjs/blob/fed202eef84f6a39f131f42d3dbaf573bafe224b/src/utils.coffee | 89 | 96 |
discolabs/cartjs:src/utils.coffee:2:raw_corpus | raw_corpus | # Extend a source object with the properties of another object.
#
# Can be used to shallow copy an object like so:
# copy = extend({}, original)
extend: (object, properties) ->
for key, val of properties
object[key] = val
object
# Clone a source object (deep copy).
clone: (object) ->
if... | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 1beabacda6ffdf67ad6cb0ac6ef024eab867584e | 493 | https://github.com/discolabs/cartjs/blob/1beabacda6ffdf67ad6cb0ac6ef024eab867584e/src/utils.coffee | 48 | 86 | ||
discolabs/cartjs:src/utils.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# Extend a source object with the properties of another object.
#
# Can be used to shallow copy an object like so:
# copy = extend({}, original)
extend: (object, properties) ->
for key, val of properties
object[key] = val
object
# Clone... | // Extend a source object with the properties of another object.
// Can be used to shallow copy an object like so:
// copy = extend({}, original)
({
extend: function(object, properties) {
var key, val;
for (key in properties) {
val = properties[key];
object[key] = val;
}
return object;
... | CoffeeScript | JavaScript | discolabs/cartjs | src/utils.coffee | MIT | 1beabacda6ffdf67ad6cb0ac6ef024eab867584e | 493 | https://github.com/discolabs/cartjs/blob/1beabacda6ffdf67ad6cb0ac6ef024eab867584e/src/utils.coffee | 48 | 86 |
discolabs/cartjs:src/utils.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// Extend a source object with the properties of another object.
// Can be used to shallow copy an object like so:
// copy = extend({}, original)
({
extend: function(object, properties) {
var key, val;
for (key in properties) {
val = properties[k... | # Extend a source object with the properties of another object.
#
# Can be used to shallow copy an object like so:
# copy = extend({}, original)
extend: (object, properties) ->
for key, val of properties
object[key] = val
object
# Clone a source object (deep copy).
clone: (object) ->
if... | JavaScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 1beabacda6ffdf67ad6cb0ac6ef024eab867584e | 493 | https://github.com/discolabs/cartjs/blob/1beabacda6ffdf67ad6cb0ac6ef024eab867584e/src/utils.coffee | 48 | 86 |
discolabs/cartjs:src/utils.coffee:2:completion | completion | # Extend a source object with the properties of another object.
#
# Can be used to shallow copy an object like so:
# copy = extend({}, original)
extend: (object, properties) ->
for key, val of properties
object[key] = val
object
# Clone a source object (deep copy).
clone: (object) ->
if... | isArray: Array.isArray || (value) ->
{}.toString.call(value) is '[object Array]'
# Ensure that the given value is returned as an array, either with entries intact or as a blank value.
ensureArray: (value) ->
if CartJS.Utils.isArray(value)
return value
if value? then [value] else []
# Format a ... | CoffeeScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 1beabacda6ffdf67ad6cb0ac6ef024eab867584e | 493 | https://github.com/discolabs/cartjs/blob/1beabacda6ffdf67ad6cb0ac6ef024eab867584e/src/utils.coffee | 48 | 86 |
discolabs/cartjs:src/utils.coffee:2:raw_corpus | raw_corpus | # Extend a source object with the properties of another object.
#
# Can be used to shallow copy an object like so:
# copy = extend({}, original)
extend: (object, properties) ->
for key, val of properties
object[key] = val
object
# Clone a source object (deep copy).
clone: (object) ->
if... | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 556a2cd6bb28df7c6d64aadbfb4776c3020aaca6 | 493 | https://github.com/discolabs/cartjs/blob/556a2cd6bb28df7c6d64aadbfb4776c3020aaca6/src/utils.coffee | 48 | 86 | ||
discolabs/cartjs:src/utils.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# Extend a source object with the properties of another object.
#
# Can be used to shallow copy an object like so:
# copy = extend({}, original)
extend: (object, properties) ->
for key, val of properties
object[key] = val
object
# Clone... | // Extend a source object with the properties of another object.
// Can be used to shallow copy an object like so:
// copy = extend({}, original)
({
extend: function(object, properties) {
var key, val;
for (key in properties) {
val = properties[key];
object[key] = val;
}
return object;
... | CoffeeScript | JavaScript | discolabs/cartjs | src/utils.coffee | MIT | 556a2cd6bb28df7c6d64aadbfb4776c3020aaca6 | 493 | https://github.com/discolabs/cartjs/blob/556a2cd6bb28df7c6d64aadbfb4776c3020aaca6/src/utils.coffee | 48 | 86 |
discolabs/cartjs:src/utils.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// Extend a source object with the properties of another object.
// Can be used to shallow copy an object like so:
// copy = extend({}, original)
({
extend: function(object, properties) {
var key, val;
for (key in properties) {
val = properties[k... | # Extend a source object with the properties of another object.
#
# Can be used to shallow copy an object like so:
# copy = extend({}, original)
extend: (object, properties) ->
for key, val of properties
object[key] = val
object
# Clone a source object (deep copy).
clone: (object) ->
if... | JavaScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 556a2cd6bb28df7c6d64aadbfb4776c3020aaca6 | 493 | https://github.com/discolabs/cartjs/blob/556a2cd6bb28df7c6d64aadbfb4776c3020aaca6/src/utils.coffee | 48 | 86 |
discolabs/cartjs:src/utils.coffee:2:completion | completion | # Extend a source object with the properties of another object.
#
# Can be used to shallow copy an object like so:
# copy = extend({}, original)
extend: (object, properties) ->
for key, val of properties
object[key] = val
object
# Clone a source object (deep copy).
clone: (object) ->
if... | isArray: Array.isArray || (value) ->
{}.toString.call(value) is '[object Array]'
# Ensure that the given value is returned as an array, either with entries intact or as a blank value.
ensureArray: (value) ->
if CartJS.Utils.isArray(value)
return value
if value? then [value] else []
# Format a ... | CoffeeScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 556a2cd6bb28df7c6d64aadbfb4776c3020aaca6 | 493 | https://github.com/discolabs/cartjs/blob/556a2cd6bb28df7c6d64aadbfb4776c3020aaca6/src/utils.coffee | 48 | 86 |
discolabs/cartjs:src/utils.coffee:1:raw_corpus | raw_corpus | # CartJS.Utils
# Utility methods.
# ----------------
CartJS.Utils =
# Returns the given object with each key wrapped with the text specified by
# the 'type' parameter and square brackets, suitable for passing as a POST
# variable to Shopify. 'type' defaults to 'properties'.
#
# For example, {"size": "xs"} b... | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 3c7f3a800d678736a623a7068165f9c6625b99a3 | 493 | https://github.com/discolabs/cartjs/blob/3c7f3a800d678736a623a7068165f9c6625b99a3/src/utils.coffee | 1 | 50 | ||
discolabs/cartjs:src/utils.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# CartJS.Utils
# Utility methods.
# ----------------
CartJS.Utils =
# Returns the given object with each key wrapped with the text specified by
# the 'type' parameter and square brackets, suitable for passing as a POST
# variable to Shopify. 'type' defaul... | // CartJS.Utils
// Utility methods.
// ----------------
CartJS.Utils = {
// Returns the given object with each key wrapped with the text specified by
// the 'type' parameter and square brackets, suitable for passing as a POST
// variable to Shopify. 'type' defaults to 'properties'.
// For example, {"size": "xs... | CoffeeScript | JavaScript | discolabs/cartjs | src/utils.coffee | MIT | 3c7f3a800d678736a623a7068165f9c6625b99a3 | 493 | https://github.com/discolabs/cartjs/blob/3c7f3a800d678736a623a7068165f9c6625b99a3/src/utils.coffee | 1 | 50 |
discolabs/cartjs:src/utils.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// CartJS.Utils
// Utility methods.
// ----------------
CartJS.Utils = {
// Returns the given object with each key wrapped with the text specified by
// the 'type' parameter and square brackets, suitable for passing as a POST
// variable to Shopify. 'type' de... | # CartJS.Utils
# Utility methods.
# ----------------
CartJS.Utils =
# Returns the given object with each key wrapped with the text specified by
# the 'type' parameter and square brackets, suitable for passing as a POST
# variable to Shopify. 'type' defaults to 'properties'.
#
# For example, {"size": "xs"} b... | JavaScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 3c7f3a800d678736a623a7068165f9c6625b99a3 | 493 | https://github.com/discolabs/cartjs/blob/3c7f3a800d678736a623a7068165f9c6625b99a3/src/utils.coffee | 1 | 50 |
discolabs/cartjs:src/utils.coffee:1:completion | completion | # CartJS.Utils
# Utility methods.
# ----------------
CartJS.Utils =
# Returns the given object with each key wrapped with the text specified by
# the 'type' parameter and square brackets, suitable for passing as a POST
# variable to Shopify. 'type' defaults to 'properties'.
#
# For example, {"size": "xs"} b... | # For example, {"properties[size]": "xs"} becomes {"size": "xs"}.
unwrapKeys: (obj, type = 'properties', override) ->
unwrapped = {}
for key, value of obj
unwrappedKey = key.replace("#{type}[", "").replace("]", "")
unwrapped[unwrappedKey] = if override? then override else value
unwrapped
# ... | CoffeeScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 3c7f3a800d678736a623a7068165f9c6625b99a3 | 493 | https://github.com/discolabs/cartjs/blob/3c7f3a800d678736a623a7068165f9c6625b99a3/src/utils.coffee | 1 | 50 |
discolabs/cartjs:src/utils.coffee:2:raw_corpus | raw_corpus | # Return true if the given value is an array.
isArray: Array.isArray || (value) ->
{}.toString.call(value) is '[object Array]'
# Ensure that the given value is returned as an array, either with entries intact or as a blank value.
ensureArray: (value) ->
if CartJS.Utils.isArray(value)
return value
... | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 3c7f3a800d678736a623a7068165f9c6625b99a3 | 493 | https://github.com/discolabs/cartjs/blob/3c7f3a800d678736a623a7068165f9c6625b99a3/src/utils.coffee | 51 | 71 | ||
discolabs/cartjs:src/utils.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# Return true if the given value is an array.
isArray: Array.isArray || (value) ->
{}.toString.call(value) is '[object Array]'
# Ensure that the given value is returned as an array, either with entries intact or as a blank value.
ensureArray: (value) -... | // Return true if the given value is an array.
({
isArray: Array.isArray || function(value) {
return {}.toString.call(value) === '[object Array]';
},
// Ensure that the given value is returned as an array, either with entries intact or as a blank value.
ensureArray: function(value) {
if (CartJS.Utils.is... | CoffeeScript | JavaScript | discolabs/cartjs | src/utils.coffee | MIT | 3c7f3a800d678736a623a7068165f9c6625b99a3 | 493 | https://github.com/discolabs/cartjs/blob/3c7f3a800d678736a623a7068165f9c6625b99a3/src/utils.coffee | 51 | 71 |
discolabs/cartjs:src/utils.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// Return true if the given value is an array.
({
isArray: Array.isArray || function(value) {
return {}.toString.call(value) === '[object Array]';
},
// Ensure that the given value is returned as an array, either with entries intact or as a blank value.
... | # Return true if the given value is an array.
isArray: Array.isArray || (value) ->
{}.toString.call(value) is '[object Array]'
# Ensure that the given value is returned as an array, either with entries intact or as a blank value.
ensureArray: (value) ->
if CartJS.Utils.isArray(value)
return value
... | JavaScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 3c7f3a800d678736a623a7068165f9c6625b99a3 | 493 | https://github.com/discolabs/cartjs/blob/3c7f3a800d678736a623a7068165f9c6625b99a3/src/utils.coffee | 51 | 71 |
discolabs/cartjs:src/utils.coffee:2:completion | completion | # Return true if the given value is an array.
isArray: Array.isArray || (value) ->
{}.toString.call(value) is '[object Array]'
# Ensure that the given value is returned as an array, either with entries intact or as a blank value.
ensureArray: (value) ->
if CartJS.Utils.isArray(value)
return value
... | # Format a monetary amount using Shopify's formatMoney if available.
#
# If it's not available, just return the value.
formatMoney: (value, format) ->
if window.Shopify?.formatMoney? then Shopify.formatMoney(value, format) else value
# Return a resized image URL using Shopify's getSizedImageUrl if availab... | CoffeeScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 3c7f3a800d678736a623a7068165f9c6625b99a3 | 493 | https://github.com/discolabs/cartjs/blob/3c7f3a800d678736a623a7068165f9c6625b99a3/src/utils.coffee | 51 | 71 |
discolabs/cartjs:src/utils.coffee:2:raw_corpus | raw_corpus | # Format a monetary amount using Shopify's formatMoney if available.
#
# If it's not available, just return the value.
formatMoney: (value, format) ->
if window.Shopify?.formatMoney? then Shopify.formatMoney(value, format) else value
# Return a resized image URL using Shopify's getSizedImageUrl if availab... | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | e8bb01175f6879d27b7f816c4bdb6e5d1bbf0223 | 493 | https://github.com/discolabs/cartjs/blob/e8bb01175f6879d27b7f816c4bdb6e5d1bbf0223/src/utils.coffee | 51 | 61 | ||
discolabs/cartjs:src/utils.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# Format a monetary amount using Shopify's formatMoney if available.
#
# If it's not available, just return the value.
formatMoney: (value, format) ->
if window.Shopify?.formatMoney? then Shopify.formatMoney(value, format) else value
# Return a resi... | // Format a monetary amount using Shopify's formatMoney if available.
// If it's not available, just return the value.
({
formatMoney: function(value, format) {
var ref;
if (((ref = window.Shopify) != null ? ref.formatMoney : void 0) != null) {
return Shopify.formatMoney(value, format);
} else {
... | CoffeeScript | JavaScript | discolabs/cartjs | src/utils.coffee | MIT | e8bb01175f6879d27b7f816c4bdb6e5d1bbf0223 | 493 | https://github.com/discolabs/cartjs/blob/e8bb01175f6879d27b7f816c4bdb6e5d1bbf0223/src/utils.coffee | 51 | 61 |
discolabs/cartjs:src/utils.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// Format a monetary amount using Shopify's formatMoney if available.
// If it's not available, just return the value.
({
formatMoney: function(value, format) {
var ref;
if (((ref = window.Shopify) != null ? ref.formatMoney : void 0) != null) {
ret... | # Format a monetary amount using Shopify's formatMoney if available.
#
# If it's not available, just return the value.
formatMoney: (value, format) ->
if window.Shopify?.formatMoney? then Shopify.formatMoney(value, format) else value
# Return a resized image URL using Shopify's getSizedImageUrl if availab... | JavaScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | e8bb01175f6879d27b7f816c4bdb6e5d1bbf0223 | 493 | https://github.com/discolabs/cartjs/blob/e8bb01175f6879d27b7f816c4bdb6e5d1bbf0223/src/utils.coffee | 51 | 61 |
discolabs/cartjs:src/utils.coffee:2:completion | completion | # Format a monetary amount using Shopify's formatMoney if available.
#
# If it's not available, just return the value.
formatMoney: (value, format) ->
if window.Shopify?.formatMoney? then Shopify.formatMoney(value, format) else value | # Return a resized image URL using Shopify's getSizedImageUrl if available.
#
# If it's not available, just return the original URL.
getSizedImageUrl: (src, size) ->
if window.Shopify?.Image?.getSizedImageUrl? then Shopify.Image.getSizedImageUrl(src, size) else src | CoffeeScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | e8bb01175f6879d27b7f816c4bdb6e5d1bbf0223 | 493 | https://github.com/discolabs/cartjs/blob/e8bb01175f6879d27b7f816c4bdb6e5d1bbf0223/src/utils.coffee | 51 | 61 |
discolabs/cartjs:src/utils.coffee:1:raw_corpus | raw_corpus | # CartJS.Utils
# Utility methods.
# ----------------
CartJS.Utils =
# Returns the given object with each key wrapped with the text specified by
# the 'type' parameter and square brackets, suitable for passing as a POST
# variable to Shopify. 'type' defaults to 'properties'.
#
# For example, {"size": "xs"} b... | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | deb7f2f9f0b533183c1011d1fe09a40dd4dc410d | 493 | https://github.com/discolabs/cartjs/blob/deb7f2f9f0b533183c1011d1fe09a40dd4dc410d/src/utils.coffee | 1 | 46 | ||
discolabs/cartjs:src/utils.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# CartJS.Utils
# Utility methods.
# ----------------
CartJS.Utils =
# Returns the given object with each key wrapped with the text specified by
# the 'type' parameter and square brackets, suitable for passing as a POST
# variable to Shopify. 'type' defaul... | // CartJS.Utils
// Utility methods.
// ----------------
CartJS.Utils = {
// Returns the given object with each key wrapped with the text specified by
// the 'type' parameter and square brackets, suitable for passing as a POST
// variable to Shopify. 'type' defaults to 'properties'.
// For example, {"size": "xs... | CoffeeScript | JavaScript | discolabs/cartjs | src/utils.coffee | MIT | deb7f2f9f0b533183c1011d1fe09a40dd4dc410d | 493 | https://github.com/discolabs/cartjs/blob/deb7f2f9f0b533183c1011d1fe09a40dd4dc410d/src/utils.coffee | 1 | 46 |
discolabs/cartjs:src/utils.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// CartJS.Utils
// Utility methods.
// ----------------
CartJS.Utils = {
// Returns the given object with each key wrapped with the text specified by
// the 'type' parameter and square brackets, suitable for passing as a POST
// variable to Shopify. 'type' de... | # CartJS.Utils
# Utility methods.
# ----------------
CartJS.Utils =
# Returns the given object with each key wrapped with the text specified by
# the 'type' parameter and square brackets, suitable for passing as a POST
# variable to Shopify. 'type' defaults to 'properties'.
#
# For example, {"size": "xs"} b... | JavaScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | deb7f2f9f0b533183c1011d1fe09a40dd4dc410d | 493 | https://github.com/discolabs/cartjs/blob/deb7f2f9f0b533183c1011d1fe09a40dd4dc410d/src/utils.coffee | 1 | 46 |
discolabs/cartjs:src/utils.coffee:1:completion | completion | # CartJS.Utils
# Utility methods.
# ----------------
CartJS.Utils =
# Returns the given object with each key wrapped with the text specified by
# the 'type' parameter and square brackets, suitable for passing as a POST
# variable to Shopify. 'type' defaults to 'properties'.
#
# For example, {"size": "xs"} b... | #
# For example, {"properties[size]": "xs"} becomes {"size": "xs"}.
unwrapKeys: (obj, type = 'properties', override) ->
unwrapped = {}
for key, value of obj
unwrappedKey = key.replace("#{type}[", "").replace("]", "")
unwrapped[unwrappedKey] = if override? then override else value
unwrapped
... | CoffeeScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | deb7f2f9f0b533183c1011d1fe09a40dd4dc410d | 493 | https://github.com/discolabs/cartjs/blob/deb7f2f9f0b533183c1011d1fe09a40dd4dc410d/src/utils.coffee | 1 | 46 |
discolabs/cartjs:src/utils.coffee:1:raw_corpus | raw_corpus | # CartJS.Utils
# Utility methods.
# ----------------
CartJS.Utils =
# Returns the given object with each key wrapped with the text specified by
# the 'type' parameter and square brackets, suitable for passing as a POST
# variable to Shopify. 'type' defaults to 'properties'.
#
# For example, {"size": "xs"} b... | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 0241b35820e1dcecd0154552b444d3c2fe8422d0 | 493 | https://github.com/discolabs/cartjs/blob/0241b35820e1dcecd0154552b444d3c2fe8422d0/src/utils.coffee | 1 | 16 | ||
discolabs/cartjs:src/utils.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# CartJS.Utils
# Utility methods.
# ----------------
CartJS.Utils =
# Returns the given object with each key wrapped with the text specified by
# the 'type' parameter and square brackets, suitable for passing as a POST
# variable to Shopify. 'type' defaul... | // CartJS.Utils
// Utility methods.
// ----------------
CartJS.Utils = {
// Returns the given object with each key wrapped with the text specified by
// the 'type' parameter and square brackets, suitable for passing as a POST
// variable to Shopify. 'type' defaults to 'properties'.
// For example, {"size": "xs... | CoffeeScript | JavaScript | discolabs/cartjs | src/utils.coffee | MIT | 0241b35820e1dcecd0154552b444d3c2fe8422d0 | 493 | https://github.com/discolabs/cartjs/blob/0241b35820e1dcecd0154552b444d3c2fe8422d0/src/utils.coffee | 1 | 16 |
discolabs/cartjs:src/utils.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// CartJS.Utils
// Utility methods.
// ----------------
CartJS.Utils = {
// Returns the given object with each key wrapped with the text specified by
// the 'type' parameter and square brackets, suitable for passing as a POST
// variable to Shopify. 'type' de... | # CartJS.Utils
# Utility methods.
# ----------------
CartJS.Utils =
# Returns the given object with each key wrapped with the text specified by
# the 'type' parameter and square brackets, suitable for passing as a POST
# variable to Shopify. 'type' defaults to 'properties'.
#
# For example, {"size": "xs"} b... | JavaScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 0241b35820e1dcecd0154552b444d3c2fe8422d0 | 493 | https://github.com/discolabs/cartjs/blob/0241b35820e1dcecd0154552b444d3c2fe8422d0/src/utils.coffee | 1 | 16 |
discolabs/cartjs:src/utils.coffee:1:completion | completion | # CartJS.Utils
# Utility methods.
# ----------------
CartJS.Utils =
# Returns the given object with each key wrapped with the text specified by
# the 'type' parameter and square brackets, suitable for passing as a POST | # variable to Shopify. 'type' defaults to 'properties'.
#
# For example, {"size": "xs"} becomes {"properties[size]": "xs"}.
wrapKeys: (obj, type = 'properties') ->
wrapped = {}
for key, value of obj
wrapped["#{type}[#{key}]"] = value
wrapped | CoffeeScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 0241b35820e1dcecd0154552b444d3c2fe8422d0 | 493 | https://github.com/discolabs/cartjs/blob/0241b35820e1dcecd0154552b444d3c2fe8422d0/src/utils.coffee | 1 | 16 |
discolabs/cartjs:src/utils.coffee:1:raw_corpus | raw_corpus | # Utility methods.
# ----------------
wrapKeys = (obj, type = 'attributes') ->
wrapped = {}
for key, value of obj
wrapped["#{type}[#{key}]"] = value
wrapped | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | d848db3917551fe1d95aa75a906010b206efc0e9 | 493 | https://github.com/discolabs/cartjs/blob/d848db3917551fe1d95aa75a906010b206efc0e9/src/utils.coffee | 1 | 8 | ||
discolabs/cartjs:src/utils.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# Utility methods.
# ----------------
wrapKeys = (obj, type = 'attributes') ->
wrapped = {}
for key, value of obj
wrapped["#{type}[#{key}]"] = value
wrapped
``` | // Utility methods.
// ----------------
var wrapKeys;
wrapKeys = function(obj, type = 'attributes') {
var key, value, wrapped;
wrapped = {};
for (key in obj) {
value = obj[key];
wrapped[`${type}[${key}]`] = value;
}
return wrapped;
}; | CoffeeScript | JavaScript | discolabs/cartjs | src/utils.coffee | MIT | d848db3917551fe1d95aa75a906010b206efc0e9 | 493 | https://github.com/discolabs/cartjs/blob/d848db3917551fe1d95aa75a906010b206efc0e9/src/utils.coffee | 1 | 8 |
discolabs/cartjs:src/utils.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// Utility methods.
// ----------------
var wrapKeys;
wrapKeys = function(obj, type = 'attributes') {
var key, value, wrapped;
wrapped = {};
for (key in obj) {
value = obj[key];
wrapped[`${type}[${key}]`] = value;
}
return wrapped;
};
``` | # Utility methods.
# ----------------
wrapKeys = (obj, type = 'attributes') ->
wrapped = {}
for key, value of obj
wrapped["#{type}[#{key}]"] = value
wrapped | JavaScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | d848db3917551fe1d95aa75a906010b206efc0e9 | 493 | https://github.com/discolabs/cartjs/blob/d848db3917551fe1d95aa75a906010b206efc0e9/src/utils.coffee | 1 | 8 |
discolabs/cartjs:src/utils.coffee:1:completion | completion | # Utility methods.
# ----------------
wrapKeys = (obj, type = 'attributes') -> | wrapped = {}
for key, value of obj
wrapped["#{type}[#{key}]"] = value
wrapped | CoffeeScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | d848db3917551fe1d95aa75a906010b206efc0e9 | 493 | https://github.com/discolabs/cartjs/blob/d848db3917551fe1d95aa75a906010b206efc0e9/src/utils.coffee | 1 | 8 |
discolabs/cartjs:src/utils.coffee:1:raw_corpus | raw_corpus | # Utility methods.
# ----------------
Cart.wrapKeys = (obj, type = 'attributes') ->
wrapped = {}
for key, value of obj
wrapped["#{type}[#{key}]"] = value
wrapped | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 405adbcf3257d4584ade700660fc6eef5c97692b | 493 | https://github.com/discolabs/cartjs/blob/405adbcf3257d4584ade700660fc6eef5c97692b/src/utils.coffee | 1 | 8 | ||
discolabs/cartjs:src/utils.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# Utility methods.
# ----------------
Cart.wrapKeys = (obj, type = 'attributes') ->
wrapped = {}
for key, value of obj
wrapped["#{type}[#{key}]"] = value
wrapped
``` | // Utility methods.
// ----------------
Cart.wrapKeys = function(obj, type = 'attributes') {
var key, value, wrapped;
wrapped = {};
for (key in obj) {
value = obj[key];
wrapped[`${type}[${key}]`] = value;
}
return wrapped;
}; | CoffeeScript | JavaScript | discolabs/cartjs | src/utils.coffee | MIT | 405adbcf3257d4584ade700660fc6eef5c97692b | 493 | https://github.com/discolabs/cartjs/blob/405adbcf3257d4584ade700660fc6eef5c97692b/src/utils.coffee | 1 | 8 |
discolabs/cartjs:src/utils.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// Utility methods.
// ----------------
Cart.wrapKeys = function(obj, type = 'attributes') {
var key, value, wrapped;
wrapped = {};
for (key in obj) {
value = obj[key];
wrapped[`${type}[${key}]`] = value;
}
return wrapped;
};
``` | # Utility methods.
# ----------------
Cart.wrapKeys = (obj, type = 'attributes') ->
wrapped = {}
for key, value of obj
wrapped["#{type}[#{key}]"] = value
wrapped | JavaScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 405adbcf3257d4584ade700660fc6eef5c97692b | 493 | https://github.com/discolabs/cartjs/blob/405adbcf3257d4584ade700660fc6eef5c97692b/src/utils.coffee | 1 | 8 |
discolabs/cartjs:src/utils.coffee:1:completion | completion | # Utility methods.
# ----------------
Cart.wrapKeys = (obj, type = 'attributes') -> | wrapped = {}
for key, value of obj
wrapped["#{type}[#{key}]"] = value
wrapped | CoffeeScript | CoffeeScript | discolabs/cartjs | src/utils.coffee | MIT | 405adbcf3257d4584ade700660fc6eef5c97692b | 493 | https://github.com/discolabs/cartjs/blob/405adbcf3257d4584ade700660fc6eef5c97692b/src/utils.coffee | 1 | 8 |
CaryLandholt/AngularFun:src/scripts/bootstrap.coffee:1:raw_corpus | raw_corpus | do (angular, window) ->
'use strict'
angular.bootstrap window.document, ['app'] | CoffeeScript | CaryLandholt/AngularFun | src/scripts/bootstrap.coffee | MIT | 84cd4633279ad391623504698a20ed4b5560dc77 | 672 | https://github.com/CaryLandholt/AngularFun/blob/84cd4633279ad391623504698a20ed4b5560dc77/src/scripts/bootstrap.coffee | 1 | 4 | ||
CaryLandholt/AngularFun:src/scripts/bootstrap.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
do (angular, window) ->
'use strict'
angular.bootstrap window.document, ['app']
``` | (function(angular, window) {
'use strict';
return angular.bootstrap(window.document, ['app']);
})(angular, window); | CoffeeScript | JavaScript | CaryLandholt/AngularFun | src/scripts/bootstrap.coffee | MIT | 84cd4633279ad391623504698a20ed4b5560dc77 | 672 | https://github.com/CaryLandholt/AngularFun/blob/84cd4633279ad391623504698a20ed4b5560dc77/src/scripts/bootstrap.coffee | 1 | 4 |
CaryLandholt/AngularFun:src/scripts/bootstrap.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
(function(angular, window) {
'use strict';
return angular.bootstrap(window.document, ['app']);
})(angular, window);
``` | do (angular, window) ->
'use strict'
angular.bootstrap window.document, ['app'] | JavaScript | CoffeeScript | CaryLandholt/AngularFun | src/scripts/bootstrap.coffee | MIT | 84cd4633279ad391623504698a20ed4b5560dc77 | 672 | https://github.com/CaryLandholt/AngularFun/blob/84cd4633279ad391623504698a20ed4b5560dc77/src/scripts/bootstrap.coffee | 1 | 4 |
CaryLandholt/AngularFun:src/scripts/bootstrap.coffee:1:completion | completion | do (angular, window) ->
'use strict' | angular.bootstrap window.document, ['app'] | CoffeeScript | CoffeeScript | CaryLandholt/AngularFun | src/scripts/bootstrap.coffee | MIT | 84cd4633279ad391623504698a20ed4b5560dc77 | 672 | https://github.com/CaryLandholt/AngularFun/blob/84cd4633279ad391623504698a20ed4b5560dc77/src/scripts/bootstrap.coffee | 1 | 4 |
jianliaoim/talk-os:talk-web/client/module/no-result.coffee:1:raw_corpus | raw_corpus | React = require 'react'
PureRenderMixin = require 'react-addons-pure-render-mixin'
div = React.createFactory 'div'
span = React.createFactory 'span'
lang = require '../locales/lang'
module.exports = React.createClass
displayName: 'no-result'
mixins: [PureRenderMixin]
render: ->
div className: 'no-result n... | CoffeeScript | jianliaoim/talk-os | talk-web/client/module/no-result.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/module/no-result.coffee | 1 | 16 | ||
jianliaoim/talk-os:talk-web/client/module/no-result.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
React = require 'react'
PureRenderMixin = require 'react-addons-pure-render-mixin'
div = React.createFactory 'div'
span = React.createFactory 'span'
lang = require '../locales/lang'
module.exports = React.createClass
displayName: 'no-result'
mixins: [PureR... | var PureRenderMixin, React, div, lang, span;
React = require('react');
PureRenderMixin = require('react-addons-pure-render-mixin');
div = React.createFactory('div');
span = React.createFactory('span');
lang = require('../locales/lang');
module.exports = React.createClass({
displayName: 'no-result',
mixins: [P... | CoffeeScript | JavaScript | jianliaoim/talk-os | talk-web/client/module/no-result.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/module/no-result.coffee | 1 | 16 |
jianliaoim/talk-os:talk-web/client/module/no-result.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var PureRenderMixin, React, div, lang, span;
React = require('react');
PureRenderMixin = require('react-addons-pure-render-mixin');
div = React.createFactory('div');
span = React.createFactory('span');
lang = require('../locales/lang');
module.exports = React... | React = require 'react'
PureRenderMixin = require 'react-addons-pure-render-mixin'
div = React.createFactory 'div'
span = React.createFactory 'span'
lang = require '../locales/lang'
module.exports = React.createClass
displayName: 'no-result'
mixins: [PureRenderMixin]
render: ->
div className: 'no-result n... | JavaScript | CoffeeScript | jianliaoim/talk-os | talk-web/client/module/no-result.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/module/no-result.coffee | 1 | 16 |
jianliaoim/talk-os:talk-web/client/module/no-result.coffee:1:completion | completion | React = require 'react'
PureRenderMixin = require 'react-addons-pure-render-mixin'
div = React.createFactory 'div'
span = React.createFactory 'span'
lang = require '../locales/lang'
module.exports = React.createClass | displayName: 'no-result'
mixins: [PureRenderMixin]
render: ->
div className: 'no-result no-favorite',
span className: "ti ti-alert-solid"
div className: "message", lang.getText('no-results')
div className: 'tip', lang.getText('no-results-need-keywords') | CoffeeScript | CoffeeScript | jianliaoim/talk-os | talk-web/client/module/no-result.coffee | MIT | 2545c4497865779a55762e03963a39237df9046b | 2,703 | https://github.com/jianliaoim/talk-os/blob/2545c4497865779a55762e03963a39237df9046b/talk-web/client/module/no-result.coffee | 1 | 16 |
octoblu/meshblu:test/controllers/authenticate-controller-spec.coffee:1:raw_corpus | raw_corpus | {EventEmitter} = require 'events'
httpMocks = require 'node-mocks-http'
AuthenticateController = require '../../src/controllers/authenticate-controller'
describe 'AuthenticateController', ->
describe 'authenticate', ->
beforeEach ->
@authenticator = authenticate: sinon.stub()
@sut = new Authenti... | CoffeeScript | octoblu/meshblu | test/controllers/authenticate-controller-spec.coffee | MIT | 12672e10627e690e2e56bba865f71c38b8a90f25 | 815 | https://github.com/octoblu/meshblu/blob/12672e10627e690e2e56bba865f71c38b8a90f25/test/controllers/authenticate-controller-spec.coffee | 1 | 50 | ||
octoblu/meshblu:test/controllers/authenticate-controller-spec.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
{EventEmitter} = require 'events'
httpMocks = require 'node-mocks-http'
AuthenticateController = require '../../src/controllers/authenticate-controller'
describe 'AuthenticateController', ->
describe 'authenticate', ->
beforeEach ->
@authenticat... | var AuthenticateController, EventEmitter, httpMocks;
({EventEmitter} = require('events'));
httpMocks = require('node-mocks-http');
AuthenticateController = require('../../src/controllers/authenticate-controller');
describe('AuthenticateController', function() {
return describe('authenticate', function() {
bef... | CoffeeScript | JavaScript | octoblu/meshblu | test/controllers/authenticate-controller-spec.coffee | MIT | 12672e10627e690e2e56bba865f71c38b8a90f25 | 815 | https://github.com/octoblu/meshblu/blob/12672e10627e690e2e56bba865f71c38b8a90f25/test/controllers/authenticate-controller-spec.coffee | 1 | 50 |
octoblu/meshblu:test/controllers/authenticate-controller-spec.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var AuthenticateController, EventEmitter, httpMocks;
({EventEmitter} = require('events'));
httpMocks = require('node-mocks-http');
AuthenticateController = require('../../src/controllers/authenticate-controller');
describe('AuthenticateController', function() {... | {EventEmitter} = require 'events'
httpMocks = require 'node-mocks-http'
AuthenticateController = require '../../src/controllers/authenticate-controller'
describe 'AuthenticateController', ->
describe 'authenticate', ->
beforeEach ->
@authenticator = authenticate: sinon.stub()
@sut = new Authenti... | JavaScript | CoffeeScript | octoblu/meshblu | test/controllers/authenticate-controller-spec.coffee | MIT | 12672e10627e690e2e56bba865f71c38b8a90f25 | 815 | https://github.com/octoblu/meshblu/blob/12672e10627e690e2e56bba865f71c38b8a90f25/test/controllers/authenticate-controller-spec.coffee | 1 | 50 |
octoblu/meshblu:test/controllers/authenticate-controller-spec.coffee:1:completion | completion | {EventEmitter} = require 'events'
httpMocks = require 'node-mocks-http'
AuthenticateController = require '../../src/controllers/authenticate-controller'
describe 'AuthenticateController', ->
describe 'authenticate', ->
beforeEach ->
@authenticator = authenticate: sinon.stub()
@sut = new Authenti... | describe 'when called with a request containing correct auth information', ->
beforeEach (done) ->
basicAuth = new Buffer("uuid:token").toString 'base64'
@request = httpMocks.createRequest headers: authorization: "Basic #{basicAuth}"
@response = httpMocks.createResponse eventEmitt... | CoffeeScript | CoffeeScript | octoblu/meshblu | test/controllers/authenticate-controller-spec.coffee | MIT | 12672e10627e690e2e56bba865f71c38b8a90f25 | 815 | https://github.com/octoblu/meshblu/blob/12672e10627e690e2e56bba865f71c38b8a90f25/test/controllers/authenticate-controller-spec.coffee | 1 | 50 |
octoblu/meshblu:test/controllers/authenticate-controller-spec.coffee:2:raw_corpus | raw_corpus | it 'should respond with a 403', ->
expect(@response.statusCode).to.equal 403
describe 'when authenticator.authenticate yields an error', ->
beforeEach ->
@authenticator.authenticate.withArgs('fatal', 'error').yields new Error("oh no!")
describe 'when called with a request containing ... | CoffeeScript | octoblu/meshblu | test/controllers/authenticate-controller-spec.coffee | MIT | 12672e10627e690e2e56bba865f71c38b8a90f25 | 815 | https://github.com/octoblu/meshblu/blob/12672e10627e690e2e56bba865f71c38b8a90f25/test/controllers/authenticate-controller-spec.coffee | 51 | 68 | ||
octoblu/meshblu:test/controllers/authenticate-controller-spec.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
it 'should respond with a 403', ->
expect(@response.statusCode).to.equal 403
describe 'when authenticator.authenticate yields an error', ->
beforeEach ->
@authenticator.authenticate.withArgs('fatal', 'error').yields new Error("oh no!"... | it('should respond with a 403', function() {
return expect(this.response.statusCode).to.equal(403);
});
describe('when authenticator.authenticate yields an error', function() {
beforeEach(function() {
return this.authenticator.authenticate.withArgs('fatal', 'error').yields(new Error("oh no!"));
});
return ... | CoffeeScript | JavaScript | octoblu/meshblu | test/controllers/authenticate-controller-spec.coffee | MIT | 12672e10627e690e2e56bba865f71c38b8a90f25 | 815 | https://github.com/octoblu/meshblu/blob/12672e10627e690e2e56bba865f71c38b8a90f25/test/controllers/authenticate-controller-spec.coffee | 51 | 68 |
octoblu/meshblu:test/controllers/authenticate-controller-spec.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
it('should respond with a 403', function() {
return expect(this.response.statusCode).to.equal(403);
});
describe('when authenticator.authenticate yields an error', function() {
beforeEach(function() {
return this.authenticator.authenticate.withArgs('fatal'... | it 'should respond with a 403', ->
expect(@response.statusCode).to.equal 403
describe 'when authenticator.authenticate yields an error', ->
beforeEach ->
@authenticator.authenticate.withArgs('fatal', 'error').yields new Error("oh no!")
describe 'when called with a request containing ... | JavaScript | CoffeeScript | octoblu/meshblu | test/controllers/authenticate-controller-spec.coffee | MIT | 12672e10627e690e2e56bba865f71c38b8a90f25 | 815 | https://github.com/octoblu/meshblu/blob/12672e10627e690e2e56bba865f71c38b8a90f25/test/controllers/authenticate-controller-spec.coffee | 51 | 68 |
octoblu/meshblu:test/controllers/authenticate-controller-spec.coffee:2:completion | completion | it 'should respond with a 403', ->
expect(@response.statusCode).to.equal 403
describe 'when authenticator.authenticate yields an error', ->
beforeEach ->
@authenticator.authenticate.withArgs('fatal', 'error').yields new Error("oh no!")
describe 'when called with a request containing ... | basicAuth = new Buffer("fatal:error").toString 'base64'
@request = httpMocks.createRequest headers: authorization: "Basic #{basicAuth}"
@response = httpMocks.createResponse eventEmitter: EventEmitter
@response.on 'end', done
@sut.authenticate @request, @response
it 'sh... | CoffeeScript | CoffeeScript | octoblu/meshblu | test/controllers/authenticate-controller-spec.coffee | MIT | 12672e10627e690e2e56bba865f71c38b8a90f25 | 815 | https://github.com/octoblu/meshblu/blob/12672e10627e690e2e56bba865f71c38b8a90f25/test/controllers/authenticate-controller-spec.coffee | 51 | 68 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee:1:raw_corpus | raw_corpus | ###
# Copyright (c) 2013-2018 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | MIT | 0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab/cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | 1 | 32 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
###
# Copyright (c) 2013-2018 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licens... | /*
* Copyright (c) 2013-2018 the original author or authors.
*
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/licenses/mit-license.php
*
* Unless required by applica... | CoffeeScript | JavaScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | MIT | 0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab/cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | 1 | 32 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
/*
* Copyright (c) 2013-2018 the original author or authors.
*
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/li... | ###
# Copyright (c) 2013-2018 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | JavaScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | MIT | 0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab/cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | 1 | 32 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee:1:completion | completion | ###
# Copyright (c) 2013-2018 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | cyclotronServices.factory 'tagService', ($http, configService) ->
{
# List of all tags
getTags: (callback) ->
q = $http.get(configService.restServiceUrl + '/tags')
q.success (tags) -> callback(tags) if _.isFunction(callback)
q.error -> alertify.error 'Cannot conn... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | MIT | 0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/0228db71d84a3138a9ffddb50d8f4f8ff37cc5ab/cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | 1 | 32 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee:1:raw_corpus | raw_corpus | ###
# Copyright (c) 2013-2015 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | MIT | 14b0e411415be801f94fe13ea6f63d5ad957c2ed | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/14b0e411415be801f94fe13ea6f63d5ad957c2ed/cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | 1 | 32 | ||
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
###
# Copyright (c) 2013-2015 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licens... | /*
* Copyright (c) 2013-2015 the original author or authors.
*
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/licenses/mit-license.php
*
* Unless required by applica... | CoffeeScript | JavaScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | MIT | 14b0e411415be801f94fe13ea6f63d5ad957c2ed | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/14b0e411415be801f94fe13ea6f63d5ad957c2ed/cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | 1 | 32 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
/*
* Copyright (c) 2013-2015 the original author or authors.
*
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/li... | ###
# Copyright (c) 2013-2015 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | JavaScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | MIT | 14b0e411415be801f94fe13ea6f63d5ad957c2ed | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/14b0e411415be801f94fe13ea6f63d5ad957c2ed/cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | 1 | 32 |
ExpediaGroup/cyclotron:cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee:1:completion | completion | ###
# Copyright (c) 2013-2015 the original author or authors.
#
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.opensource.org/licenses/mit-license.php
#
# Unless required by applicable law ... | cyclotronServices.factory 'tagService', ($http, configService) ->
{
# List of all tags
getTags: (callback) ->
q = $http.get(configService.restServiceUrl + '/tags')
q.success (tags) -> callback(tags) if _.isFunction(callback)
q.error -> alertify.error 'Cannot conn... | CoffeeScript | CoffeeScript | ExpediaGroup/cyclotron | cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | MIT | 14b0e411415be801f94fe13ea6f63d5ad957c2ed | 1,544 | https://github.com/ExpediaGroup/cyclotron/blob/14b0e411415be801f94fe13ea6f63d5ad957c2ed/cyclotron-site/app/scripts/mgmt/services/services.tagService.coffee | 1 | 32 |
octoblu/meshblu:lib/QueryThrottle.coffee:1:raw_corpus | raw_corpus | _ = require 'lodash'
debug = require('debug')('meshblu:throttle:QueryThrottle')
class QueryThrottle
constructor: ->
@queryThrottle = require('./getThrottles').query
throttle: (id, onThrottleCallback=_.noop, next=_.noop) =>
@queryThrottle.rateLimit id, (error, isLimited) =>
debug 'rateLimit', id, isL... | CoffeeScript | octoblu/meshblu | lib/QueryThrottle.coffee | MIT | abddb2d1fe67e62b46f5472d371b507f3b80cd3f | 815 | https://github.com/octoblu/meshblu/blob/abddb2d1fe67e62b46f5472d371b507f3b80cd3f/lib/QueryThrottle.coffee | 1 | 17 | ||
octoblu/meshblu:lib/QueryThrottle.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
_ = require 'lodash'
debug = require('debug')('meshblu:throttle:QueryThrottle')
class QueryThrottle
constructor: ->
@queryThrottle = require('./getThrottles').query
throttle: (id, onThrottleCallback=_.noop, next=_.noop) =>
@queryThrottle.rateLimit i... | var QueryThrottle, _, debug;
_ = require('lodash');
debug = require('debug')('meshblu:throttle:QueryThrottle');
QueryThrottle = class QueryThrottle {
constructor() {
this.throttle = this.throttle.bind(this);
this.queryThrottle = require('./getThrottles').query;
}
throttle(id, onThrottleCallback = _.no... | CoffeeScript | JavaScript | octoblu/meshblu | lib/QueryThrottle.coffee | MIT | abddb2d1fe67e62b46f5472d371b507f3b80cd3f | 815 | https://github.com/octoblu/meshblu/blob/abddb2d1fe67e62b46f5472d371b507f3b80cd3f/lib/QueryThrottle.coffee | 1 | 17 |
octoblu/meshblu:lib/QueryThrottle.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var QueryThrottle, _, debug;
_ = require('lodash');
debug = require('debug')('meshblu:throttle:QueryThrottle');
QueryThrottle = class QueryThrottle {
constructor() {
this.throttle = this.throttle.bind(this);
this.queryThrottle = require('./getThrottles... | _ = require 'lodash'
debug = require('debug')('meshblu:throttle:QueryThrottle')
class QueryThrottle
constructor: ->
@queryThrottle = require('./getThrottles').query
throttle: (id, onThrottleCallback=_.noop, next=_.noop) =>
@queryThrottle.rateLimit id, (error, isLimited) =>
debug 'rateLimit', id, isL... | JavaScript | CoffeeScript | octoblu/meshblu | lib/QueryThrottle.coffee | MIT | abddb2d1fe67e62b46f5472d371b507f3b80cd3f | 815 | https://github.com/octoblu/meshblu/blob/abddb2d1fe67e62b46f5472d371b507f3b80cd3f/lib/QueryThrottle.coffee | 1 | 17 |
octoblu/meshblu:lib/QueryThrottle.coffee:1:completion | completion | _ = require 'lodash'
debug = require('debug')('meshblu:throttle:QueryThrottle')
class QueryThrottle
constructor: ->
@queryThrottle = require('./getThrottles').query
throttle: (id, onThrottleCallback=_.noop, next=_.noop) => | @queryThrottle.rateLimit id, (error, isLimited) =>
debug 'rateLimit', id, isLimited, error?.message
return onThrottleCallback error if error?
return onThrottleCallback new Error('request exceeds rate limit') if isLimited
next()
module.exports = QueryThrottle | CoffeeScript | CoffeeScript | octoblu/meshblu | lib/QueryThrottle.coffee | MIT | abddb2d1fe67e62b46f5472d371b507f3b80cd3f | 815 | https://github.com/octoblu/meshblu/blob/abddb2d1fe67e62b46f5472d371b507f3b80cd3f/lib/QueryThrottle.coffee | 1 | 17 |
octoblu/meshblu:lib/QueryThrottle.coffee:1:raw_corpus | raw_corpus | _ = require 'lodash'
debug = require('debug')('meshblu:QueryThrottle')
class QueryThrottle
constructor: ->
@queryThrottle = require('./getThrottles').query
throttle: (id, onThrottleCallback=_.noop, next=_.noop) =>
@queryThrottle.rateLimit id, (error, isLimited) =>
debug 'rateLimit', id, isLimited
... | CoffeeScript | octoblu/meshblu | lib/QueryThrottle.coffee | MIT | c18ea41fe28ee588fe9c5b88e1f18852616f120e | 815 | https://github.com/octoblu/meshblu/blob/c18ea41fe28ee588fe9c5b88e1f18852616f120e/lib/QueryThrottle.coffee | 1 | 17 | ||
octoblu/meshblu:lib/QueryThrottle.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
_ = require 'lodash'
debug = require('debug')('meshblu:QueryThrottle')
class QueryThrottle
constructor: ->
@queryThrottle = require('./getThrottles').query
throttle: (id, onThrottleCallback=_.noop, next=_.noop) =>
@queryThrottle.rateLimit id, (error... | var QueryThrottle, _, debug;
_ = require('lodash');
debug = require('debug')('meshblu:QueryThrottle');
QueryThrottle = class QueryThrottle {
constructor() {
this.throttle = this.throttle.bind(this);
this.queryThrottle = require('./getThrottles').query;
}
throttle(id, onThrottleCallback = _.noop, next ... | CoffeeScript | JavaScript | octoblu/meshblu | lib/QueryThrottle.coffee | MIT | c18ea41fe28ee588fe9c5b88e1f18852616f120e | 815 | https://github.com/octoblu/meshblu/blob/c18ea41fe28ee588fe9c5b88e1f18852616f120e/lib/QueryThrottle.coffee | 1 | 17 |
octoblu/meshblu:lib/QueryThrottle.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var QueryThrottle, _, debug;
_ = require('lodash');
debug = require('debug')('meshblu:QueryThrottle');
QueryThrottle = class QueryThrottle {
constructor() {
this.throttle = this.throttle.bind(this);
this.queryThrottle = require('./getThrottles').query;... | _ = require 'lodash'
debug = require('debug')('meshblu:QueryThrottle')
class QueryThrottle
constructor: ->
@queryThrottle = require('./getThrottles').query
throttle: (id, onThrottleCallback=_.noop, next=_.noop) =>
@queryThrottle.rateLimit id, (error, isLimited) =>
debug 'rateLimit', id, isLimited
... | JavaScript | CoffeeScript | octoblu/meshblu | lib/QueryThrottle.coffee | MIT | c18ea41fe28ee588fe9c5b88e1f18852616f120e | 815 | https://github.com/octoblu/meshblu/blob/c18ea41fe28ee588fe9c5b88e1f18852616f120e/lib/QueryThrottle.coffee | 1 | 17 |
octoblu/meshblu:lib/QueryThrottle.coffee:1:completion | completion | _ = require 'lodash'
debug = require('debug')('meshblu:QueryThrottle')
class QueryThrottle
constructor: ->
@queryThrottle = require('./getThrottles').query
throttle: (id, onThrottleCallback=_.noop, next=_.noop) => | @queryThrottle.rateLimit id, (error, isLimited) =>
debug 'rateLimit', id, isLimited
return onThrottleCallback error if error?
return onThrottleCallback new Error('request exceeds rate limit') if isLimited
next()
module.exports = QueryThrottle | CoffeeScript | CoffeeScript | octoblu/meshblu | lib/QueryThrottle.coffee | MIT | c18ea41fe28ee588fe9c5b88e1f18852616f120e | 815 | https://github.com/octoblu/meshblu/blob/c18ea41fe28ee588fe9c5b88e1f18852616f120e/lib/QueryThrottle.coffee | 1 | 17 |
octoblu/meshblu:lib/QueryThrottle.coffee:1:raw_corpus | raw_corpus | _ = require 'lodash'
debug = require('debug')('meshblu:QueryThrottle')
toobusy = require 'toobusy'
class QueryThrottle
constructor: ->
@queryThrottle = require('./getThrottles').query
throttle: (id, onThrottleCallback=_.noop, next=_.noop) =>
if toobusy()
serverTooBusyError = new Error('Server Too Bu... | CoffeeScript | octoblu/meshblu | lib/QueryThrottle.coffee | MIT | 432c25fe2000825c95dfbfd29fb4985a4ba70418 | 815 | https://github.com/octoblu/meshblu/blob/432c25fe2000825c95dfbfd29fb4985a4ba70418/lib/QueryThrottle.coffee | 1 | 29 | ||
octoblu/meshblu:lib/QueryThrottle.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
_ = require 'lodash'
debug = require('debug')('meshblu:QueryThrottle')
toobusy = require 'toobusy'
class QueryThrottle
constructor: ->
@queryThrottle = require('./getThrottles').query
throttle: (id, onThrottleCallback=_.noop, next=_.noop) =>
if toob... | var QueryThrottle, _, debug, toobusy;
_ = require('lodash');
debug = require('debug')('meshblu:QueryThrottle');
toobusy = require('toobusy');
QueryThrottle = class QueryThrottle {
constructor() {
this.throttle = this.throttle.bind(this);
this.queryThrottle = require('./getThrottles').query;
}
throttl... | CoffeeScript | JavaScript | octoblu/meshblu | lib/QueryThrottle.coffee | MIT | 432c25fe2000825c95dfbfd29fb4985a4ba70418 | 815 | https://github.com/octoblu/meshblu/blob/432c25fe2000825c95dfbfd29fb4985a4ba70418/lib/QueryThrottle.coffee | 1 | 29 |
octoblu/meshblu:lib/QueryThrottle.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var QueryThrottle, _, debug, toobusy;
_ = require('lodash');
debug = require('debug')('meshblu:QueryThrottle');
toobusy = require('toobusy');
QueryThrottle = class QueryThrottle {
constructor() {
this.throttle = this.throttle.bind(this);
this.queryThr... | _ = require 'lodash'
debug = require('debug')('meshblu:QueryThrottle')
toobusy = require 'toobusy'
class QueryThrottle
constructor: ->
@queryThrottle = require('./getThrottles').query
throttle: (id, onThrottleCallback=_.noop, next=_.noop) =>
if toobusy()
serverTooBusyError = new Error('Server Too Bu... | JavaScript | CoffeeScript | octoblu/meshblu | lib/QueryThrottle.coffee | MIT | 432c25fe2000825c95dfbfd29fb4985a4ba70418 | 815 | https://github.com/octoblu/meshblu/blob/432c25fe2000825c95dfbfd29fb4985a4ba70418/lib/QueryThrottle.coffee | 1 | 29 |
octoblu/meshblu:lib/QueryThrottle.coffee:1:completion | completion | _ = require 'lodash'
debug = require('debug')('meshblu:QueryThrottle')
toobusy = require 'toobusy'
class QueryThrottle
constructor: ->
@queryThrottle = require('./getThrottles').query
throttle: (id, onThrottleCallback=_.noop, next=_.noop) =>
if toobusy()
serverTooBusyError = new Error('Server Too Bu... | @queryThrottle.rateLimit id, (error, isLimited) =>
debug 'rateLimit', id, isLimited
if error?
error.status = 500
return onThrottleCallback error
if isLimited
rateLimitError = new Error('Rate Limit Exceeded')
rateLimitError.status = 429
return onThrottleCallbac... | CoffeeScript | CoffeeScript | octoblu/meshblu | lib/QueryThrottle.coffee | MIT | 432c25fe2000825c95dfbfd29fb4985a4ba70418 | 815 | https://github.com/octoblu/meshblu/blob/432c25fe2000825c95dfbfd29fb4985a4ba70418/lib/QueryThrottle.coffee | 1 | 29 |
dropbox/zxcvbn:test/test-scoring.coffee:2:raw_corpus | raw_corpus | approx_equal = (t, actual, expected, msg) ->
t.equal truncate_float(actual), truncate_float(expected), msg
test 'nCk', (t) ->
nCk = scoring.nCk
for [n, k, result] in [
[ 0, 0, 1 ]
[ 1, 0, 1 ]
[ 5, 0, 1 ]
[ 0, 1, 0 ]
[ 0, 5, 0 ]
[ 2, 1, 2 ]
[ 4, 2, 6 ]
[ 33, 7, 4272048 ]
... | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 89710d4c100c65307e3a68b4f21276ac5ddeffe7 | 15,961 | https://github.com/dropbox/zxcvbn/blob/89710d4c100c65307e3a68b4f21276ac5ddeffe7/test/test-scoring.coffee | 6 | 55 | ||
dropbox/zxcvbn:test/test-scoring.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
approx_equal = (t, actual, expected, msg) ->
t.equal truncate_float(actual), truncate_float(expected), msg
test 'nCk', (t) ->
nCk = scoring.nCk
for [n, k, result] in [
[ 0, 0, 1 ]
[ 1, 0, 1 ]
[ 5, 0, 1 ]
[ 0, 1, 0 ]
[ 0, 5, 0 ]
... | var approx_equal;
approx_equal = function(t, actual, expected, msg) {
return t.equal(truncate_float(actual), truncate_float(expected), msg);
};
test('nCk', function(t) {
var k, l, len, n, nCk, ref, result;
nCk = scoring.nCk;
ref = [[0, 0, 1], [1, 0, 1], [5, 0, 1], [0, 1, 0], [0, 5, 0], [2, 1, 2], [4, 2, 6], [... | CoffeeScript | JavaScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 89710d4c100c65307e3a68b4f21276ac5ddeffe7 | 15,961 | https://github.com/dropbox/zxcvbn/blob/89710d4c100c65307e3a68b4f21276ac5ddeffe7/test/test-scoring.coffee | 6 | 55 |
dropbox/zxcvbn:test/test-scoring.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var approx_equal;
approx_equal = function(t, actual, expected, msg) {
return t.equal(truncate_float(actual), truncate_float(expected), msg);
};
test('nCk', function(t) {
var k, l, len, n, nCk, ref, result;
nCk = scoring.nCk;
ref = [[0, 0, 1], [1, 0, 1], [... | approx_equal = (t, actual, expected, msg) ->
t.equal truncate_float(actual), truncate_float(expected), msg
test 'nCk', (t) ->
nCk = scoring.nCk
for [n, k, result] in [
[ 0, 0, 1 ]
[ 1, 0, 1 ]
[ 5, 0, 1 ]
[ 0, 1, 0 ]
[ 0, 5, 0 ]
[ 2, 1, 2 ]
[ 4, 2, 6 ]
[ 33, 7, 4272048 ]
... | JavaScript | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 89710d4c100c65307e3a68b4f21276ac5ddeffe7 | 15,961 | https://github.com/dropbox/zxcvbn/blob/89710d4c100c65307e3a68b4f21276ac5ddeffe7/test/test-scoring.coffee | 6 | 55 |
dropbox/zxcvbn:test/test-scoring.coffee:2:completion | completion | approx_equal = (t, actual, expected, msg) ->
t.equal truncate_float(actual), truncate_float(expected), msg
test 'nCk', (t) ->
nCk = scoring.nCk
for [n, k, result] in [
[ 0, 0, 1 ]
[ 1, 0, 1 ]
[ 5, 0, 1 ]
[ 0, 1, 0 ]
[ 0, 5, 0 ]
[ 2, 1, 2 ]
[ 4, 2, 6 ]
[ 33, 7, 4272048 ]
... | [ 1, 0 ]
[ 2, 1 ]
[ 4, 2 ]
[ 32, 5 ]
]
t.equal lg(n), result, "lg(#{n}) == #{result}"
n = 17
p = 4
approx_equal t, lg(n * p), lg(n) + lg(p), "product rule"
approx_equal t, lg(n / p), lg(n) - lg(p), "quotient rule"
approx_equal t, lg(10), 1 / Math.log10(2), "base switch rule"
approx_eq... | CoffeeScript | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 89710d4c100c65307e3a68b4f21276ac5ddeffe7 | 15,961 | https://github.com/dropbox/zxcvbn/blob/89710d4c100c65307e3a68b4f21276ac5ddeffe7/test/test-scoring.coffee | 6 | 55 |
dropbox/zxcvbn:test/test-scoring.coffee:3:raw_corpus | raw_corpus | t.equal result.match_sequence.length, 1
m0 = result.match_sequence[0]
t.equal m0.pattern, 'bruteforce'
t.equal m0.token, password
t.equal m0.cardinality, cardinality
expected = Math.round scoring.lg(Math.pow(cardinality, password.length))
t.equal Math.round(result.entropy), expected
t.equal Math.round(m0.... | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 89710d4c100c65307e3a68b4f21276ac5ddeffe7 | 15,961 | https://github.com/dropbox/zxcvbn/blob/89710d4c100c65307e3a68b4f21276ac5ddeffe7/test/test-scoring.coffee | 56 | 105 | ||
dropbox/zxcvbn:test/test-scoring.coffee:3:completion | completion | t.equal result.match_sequence.length, 1
m0 = result.match_sequence[0]
t.equal m0.pattern, 'bruteforce'
t.equal m0.token, password
t.equal m0.cardinality, cardinality
expected = Math.round scoring.lg(Math.pow(cardinality, password.length))
t.equal Math.round(result.entropy), expected
t.equal Math.round(m0.... | m0 = result.match_sequence[0]
t.equal m0.pattern, 'bruteforce'
t.deepEqual [m0.i, m0.j], [0, 2]
# -- match in the middle: bruteforce + match + bruteforce
matches = [m1] = [m(1, 8, 1)]
result = scoring.minimum_entropy_match_sequence password, matches
t.equal result.match_sequence.length, 3
t.equal result.... | CoffeeScript | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 89710d4c100c65307e3a68b4f21276ac5ddeffe7 | 15,961 | https://github.com/dropbox/zxcvbn/blob/89710d4c100c65307e3a68b4f21276ac5ddeffe7/test/test-scoring.coffee | 56 | 105 |
dropbox/zxcvbn:test/test-scoring.coffee:4:raw_corpus | raw_corpus | # when m0 fully covers m1 and m2
# -- returns [m0] when m0 has lower entropy than m1 + m2
matches = [m0, m1, m2] = [m(0, 9, 1), m(0, 3, 1), m(4, 9, 1)]
result = scoring.minimum_entropy_match_sequence password, matches
t.equal result.entropy, 1
t.deepEqual result.match_sequence, [m0]
# -- returns [m1, m2] ... | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 89710d4c100c65307e3a68b4f21276ac5ddeffe7 | 15,961 | https://github.com/dropbox/zxcvbn/blob/89710d4c100c65307e3a68b4f21276ac5ddeffe7/test/test-scoring.coffee | 106 | 155 | ||
dropbox/zxcvbn:test/test-scoring.coffee:4:completion | completion | # when m0 fully covers m1 and m2
# -- returns [m0] when m0 has lower entropy than m1 + m2
matches = [m0, m1, m2] = [m(0, 9, 1), m(0, 3, 1), m(4, 9, 1)]
result = scoring.minimum_entropy_match_sequence password, matches
t.equal result.entropy, 1
t.deepEqual result.match_sequence, [m0]
# -- returns [m1, m2] ... | ]
msg = "crack time of #{seconds} seconds has score of #{score}"
t.equal scoring.crack_time_to_score(seconds), score, msg
t.end()
test 'bruteforce cardinality', (t) ->
for [str, cardinality] in [
# beginning / middle / end of lowers range
['a', 26]
['h', 26]
['z', 26]
# sample from each... | CoffeeScript | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 89710d4c100c65307e3a68b4f21276ac5ddeffe7 | 15,961 | https://github.com/dropbox/zxcvbn/blob/89710d4c100c65307e3a68b4f21276ac5ddeffe7/test/test-scoring.coffee | 106 | 155 |
dropbox/zxcvbn:test/test-scoring.coffee:2:raw_corpus | raw_corpus | approx_equal = (t, actual, expected, msg) ->
t.equal truncate_float(actual), truncate_float(expected), msg
test 'nCk', (t) ->
nCk = scoring.nCk
for [n, k, result] in [
[ 0, 0, 1 ]
[ 1, 0, 1 ]
[ 5, 0, 1 ]
[ 0, 1, 0 ]
[ 0, 5, 0 ]
[ 2, 1, 2 ]
[ 4, 2, 6 ]
[ 33, 7, 4272048 ]
... | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 45c653007eb2ad62bf515afeb8c59fc1e3b72dc5 | 15,961 | https://github.com/dropbox/zxcvbn/blob/45c653007eb2ad62bf515afeb8c59fc1e3b72dc5/test/test-scoring.coffee | 6 | 55 | ||
dropbox/zxcvbn:test/test-scoring.coffee:2:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
approx_equal = (t, actual, expected, msg) ->
t.equal truncate_float(actual), truncate_float(expected), msg
test 'nCk', (t) ->
nCk = scoring.nCk
for [n, k, result] in [
[ 0, 0, 1 ]
[ 1, 0, 1 ]
[ 5, 0, 1 ]
[ 0, 1, 0 ]
[ 0, 5, 0 ]
... | var approx_equal;
approx_equal = function(t, actual, expected, msg) {
return t.equal(truncate_float(actual), truncate_float(expected), msg);
};
test('nCk', function(t) {
var k, l, len, n, nCk, ref, result;
nCk = scoring.nCk;
ref = [[0, 0, 1], [1, 0, 1], [5, 0, 1], [0, 1, 0], [0, 5, 0], [2, 1, 2], [4, 2, 6], [... | CoffeeScript | JavaScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 45c653007eb2ad62bf515afeb8c59fc1e3b72dc5 | 15,961 | https://github.com/dropbox/zxcvbn/blob/45c653007eb2ad62bf515afeb8c59fc1e3b72dc5/test/test-scoring.coffee | 6 | 55 |
dropbox/zxcvbn:test/test-scoring.coffee:2:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var approx_equal;
approx_equal = function(t, actual, expected, msg) {
return t.equal(truncate_float(actual), truncate_float(expected), msg);
};
test('nCk', function(t) {
var k, l, len, n, nCk, ref, result;
nCk = scoring.nCk;
ref = [[0, 0, 1], [1, 0, 1], [... | approx_equal = (t, actual, expected, msg) ->
t.equal truncate_float(actual), truncate_float(expected), msg
test 'nCk', (t) ->
nCk = scoring.nCk
for [n, k, result] in [
[ 0, 0, 1 ]
[ 1, 0, 1 ]
[ 5, 0, 1 ]
[ 0, 1, 0 ]
[ 0, 5, 0 ]
[ 2, 1, 2 ]
[ 4, 2, 6 ]
[ 33, 7, 4272048 ]
... | JavaScript | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 45c653007eb2ad62bf515afeb8c59fc1e3b72dc5 | 15,961 | https://github.com/dropbox/zxcvbn/blob/45c653007eb2ad62bf515afeb8c59fc1e3b72dc5/test/test-scoring.coffee | 6 | 55 |
dropbox/zxcvbn:test/test-scoring.coffee:2:completion | completion | approx_equal = (t, actual, expected, msg) ->
t.equal truncate_float(actual), truncate_float(expected), msg
test 'nCk', (t) ->
nCk = scoring.nCk
for [n, k, result] in [
[ 0, 0, 1 ]
[ 1, 0, 1 ]
[ 5, 0, 1 ]
[ 0, 1, 0 ]
[ 0, 5, 0 ]
[ 2, 1, 2 ]
[ 4, 2, 6 ]
[ 33, 7, 4272048 ]
... | [ 1, 0 ]
[ 2, 1 ]
[ 4, 2 ]
[ 32, 5 ]
]
t.equal lg(n), result, "lg(#{n}) == #{result}"
n = 17
p = 4
approx_equal t, lg(n * p), lg(n) + lg(p), "logarithm product rule"
approx_equal t, lg(n / p), lg(n) - lg(p), "logarithm quotient rule"
approx_equal t, lg(10), 1 / Math.log10(2), "logarithm... | CoffeeScript | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 45c653007eb2ad62bf515afeb8c59fc1e3b72dc5 | 15,961 | https://github.com/dropbox/zxcvbn/blob/45c653007eb2ad62bf515afeb8c59fc1e3b72dc5/test/test-scoring.coffee | 6 | 55 |
dropbox/zxcvbn:test/test-scoring.coffee:4:raw_corpus | raw_corpus | # when m0 fully covers m1 and m2
# -- returns [m0] when m0 has lower entropy than m1 + m2
matches = [m0, m1, m2] = [m(0, 9, 1), m(0, 3, 1), m(4, 9, 1)]
result = scoring.minimum_entropy_match_sequence password, matches
t.equal result.entropy, 1
t.deepEqual result.match_sequence, [m0]
# -- returns [m1, m2] ... | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 45c653007eb2ad62bf515afeb8c59fc1e3b72dc5 | 15,961 | https://github.com/dropbox/zxcvbn/blob/45c653007eb2ad62bf515afeb8c59fc1e3b72dc5/test/test-scoring.coffee | 106 | 118 | ||
dropbox/zxcvbn:test/test-scoring.coffee:4:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
# when m0 fully covers m1 and m2
# -- returns [m0] when m0 has lower entropy than m1 + m2
matches = [m0, m1, m2] = [m(0, 9, 1), m(0, 3, 1), m(4, 9, 1)]
result = scoring.minimum_entropy_match_sequence password, matches
t.equal result.entropy, 1
t.deepEq... | // when m0 fully covers m1 and m2
// -- returns [m0] when m0 has lower entropy than m1 + m2
var m0, m1, m2, matches, result;
matches = [m0, m1, m2] = [m(0, 9, 1), m(0, 3, 1), m(4, 9, 1)];
result = scoring.minimum_entropy_match_sequence(password, matches);
t.equal(result.entropy, 1);
t.deepEqual(result.match_sequen... | CoffeeScript | JavaScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 45c653007eb2ad62bf515afeb8c59fc1e3b72dc5 | 15,961 | https://github.com/dropbox/zxcvbn/blob/45c653007eb2ad62bf515afeb8c59fc1e3b72dc5/test/test-scoring.coffee | 106 | 118 |
dropbox/zxcvbn:test/test-scoring.coffee:4:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
// when m0 fully covers m1 and m2
// -- returns [m0] when m0 has lower entropy than m1 + m2
var m0, m1, m2, matches, result;
matches = [m0, m1, m2] = [m(0, 9, 1), m(0, 3, 1), m(4, 9, 1)];
result = scoring.minimum_entropy_match_sequence(password, matches);
t.equ... | # when m0 fully covers m1 and m2
# -- returns [m0] when m0 has lower entropy than m1 + m2
matches = [m0, m1, m2] = [m(0, 9, 1), m(0, 3, 1), m(4, 9, 1)]
result = scoring.minimum_entropy_match_sequence password, matches
t.equal result.entropy, 1
t.deepEqual result.match_sequence, [m0]
# -- returns [m1, m2] ... | JavaScript | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 45c653007eb2ad62bf515afeb8c59fc1e3b72dc5 | 15,961 | https://github.com/dropbox/zxcvbn/blob/45c653007eb2ad62bf515afeb8c59fc1e3b72dc5/test/test-scoring.coffee | 106 | 118 |
dropbox/zxcvbn:test/test-scoring.coffee:4:completion | completion | # when m0 fully covers m1 and m2
# -- returns [m0] when m0 has lower entropy than m1 + m2
matches = [m0, m1, m2] = [m(0, 9, 1), m(0, 3, 1), m(4, 9, 1)]
result = scoring.minimum_entropy_match_sequence password, matches
t.equal result.entropy, 1
t.deepEqual result.match_sequence, [m0] | # -- returns [m1, m2] when m0 has higher entropy
m0.entropy = 3
result = scoring.minimum_entropy_match_sequence password, matches
t.equal result.entropy, 2
t.deepEqual result.match_sequence, [m1, m2]
t.end() | CoffeeScript | CoffeeScript | dropbox/zxcvbn | test/test-scoring.coffee | MIT | 45c653007eb2ad62bf515afeb8c59fc1e3b72dc5 | 15,961 | https://github.com/dropbox/zxcvbn/blob/45c653007eb2ad62bf515afeb8c59fc1e3b72dc5/test/test-scoring.coffee | 106 | 118 |
abe33/atom-pigments:lib/color-scanner.coffee:1:raw_corpus | raw_corpus | countLines = null
module.exports =
class ColorScanner
constructor: ({@context}={}) ->
@parser = @context.parser
@registry = @context.registry
getRegExp: ->
new RegExp(@registry.getRegExp(), 'g')
getRegExpForScope: (scope) ->
new RegExp(@registry.getRegExpForScope(scope), 'g')
search: (text, ... | CoffeeScript | abe33/atom-pigments | lib/color-scanner.coffee | MIT | 4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4 | 518 | https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/color-scanner.coffee | 1 | 40 | ||
abe33/atom-pigments:lib/color-scanner.coffee:1:coffee_to_js | coffee_to_js | Convert this CoffeeScript to JavaScript.
```coffeescript
countLines = null
module.exports =
class ColorScanner
constructor: ({@context}={}) ->
@parser = @context.parser
@registry = @context.registry
getRegExp: ->
new RegExp(@registry.getRegExp(), 'g')
getRegExpForScope: (scope) ->
new RegExp(@r... | var ColorScanner, countLines;
countLines = null;
module.exports = ColorScanner = class ColorScanner {
constructor({context} = {}) {
this.context = context;
this.parser = this.context.parser;
this.registry = this.context.registry;
}
getRegExp() {
return new RegExp(this.registry.getRegExp(), 'g')... | CoffeeScript | JavaScript | abe33/atom-pigments | lib/color-scanner.coffee | MIT | 4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4 | 518 | https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/color-scanner.coffee | 1 | 40 |
abe33/atom-pigments:lib/color-scanner.coffee:1:js_to_coffee | js_to_coffee | Convert this JavaScript to CoffeeScript.
```javascript
var ColorScanner, countLines;
countLines = null;
module.exports = ColorScanner = class ColorScanner {
constructor({context} = {}) {
this.context = context;
this.parser = this.context.parser;
this.registry = this.context.registry;
}
getRegExp() ... | countLines = null
module.exports =
class ColorScanner
constructor: ({@context}={}) ->
@parser = @context.parser
@registry = @context.registry
getRegExp: ->
new RegExp(@registry.getRegExp(), 'g')
getRegExpForScope: (scope) ->
new RegExp(@registry.getRegExpForScope(scope), 'g')
search: (text, ... | JavaScript | CoffeeScript | abe33/atom-pigments | lib/color-scanner.coffee | MIT | 4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4 | 518 | https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/color-scanner.coffee | 1 | 40 |
abe33/atom-pigments:lib/color-scanner.coffee:1:completion | completion | countLines = null
module.exports =
class ColorScanner
constructor: ({@context}={}) ->
@parser = @context.parser
@registry = @context.registry
getRegExp: ->
new RegExp(@registry.getRegExp(), 'g')
getRegExpForScope: (scope) ->
new RegExp(@registry.getRegExpForScope(scope), 'g')
search: (text, ... | if match = regexp.exec(text)
[matchText] = match
{lastIndex} = regexp
color = @parser.parse(matchText, scope)
# return unless color?
if (index = matchText.indexOf(color.colorExpression)) > 0
lastIndex += -matchText.length + index + color.colorExpression.length
matchText ... | CoffeeScript | CoffeeScript | abe33/atom-pigments | lib/color-scanner.coffee | MIT | 4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4 | 518 | https://github.com/abe33/atom-pigments/blob/4bdef2e1ebeaa492a6c353c2fd9e7adecdebadf4/lib/color-scanner.coffee | 1 | 40 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.