<commit_before>
log = (msg...) ->
  msg.unshift "SharedCollection:"
  console?.log.apply console, msg

S4 = -> (((1 + Math.random()) * 65536) | 0).toString(16).substring(1)


# Convert Backone.js style options object based callbacks to Node.js style
# single function callbacks used in ShareJS
optionsCbToNodeCb = (options) -> (err) ->
  if err
    options?.error?()
  else
    options?.success?()


Backbone.sync = (method, model, options) ->
  console.log "METHOD", method

  # Call options.success() callback to trigger destroy event which triggers
  # synchronization to other browsers.
  if method is "delete"
    options.success()

class Backbone.SharedCollection extends Backbone.Collection

  model: Backbone.SharedModel

  @generateGUID = ->
    S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4()

  constructor: (models, opts={}) ->
    @modelTypes = opts.modelTypes or {}
    if opts.sharejsDoc
      @_syncDoc = opts.sharejsDoc

    if not @collectionId = opts.collectionId
      throw new Error "SharedCollection needs a collectionId in options!"

    @_syncAttributes = {}
    super

  handleError: (model) => (err) =>
    if err
      log "Sync error!", err
      @trigger "sharejserror", err, model
<commit_msg>Default to Basic model in Sharedcollection<commit_after>
log = (msg...) ->
  msg.unshift "SharedCollection:"
  console?.log.apply console, msg

S4 = -> (((1 + Math.random()) * 65536) | 0).toString(16).substring(1)


# Convert Backone.js style options object based callbacks to Node.js style
# single function callbacks used in ShareJS
optionsCbToNodeCb = (options) -> (err) ->
  if err
    options?.error?()
  else
    options?.success?()


Backbone.sync = (method, model, options) ->
  console.log "METHOD", method

  # Call options.success() callback to trigger destroy event which triggers
  # synchronization to other browsers.
  if method is "delete"
    options.success()

class Backbone.SharedCollection extends Backbone.Collection

  model: Backbone.Model

  @generateGUID = ->
    S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4()

  constructor: (models, opts={}) ->
    @modelTypes = opts.modelTypes or {}
    if opts.sharejsDoc
      @_syncDoc = opts.sharejsDoc

    if not @collectionId = opts.collectionId
      throw new Error "SharedCollection needs a collectionId in options!"

    @_syncAttributes = {}
    super

  handleError: (model) => (err) =>
    if err
      log "Sync error!", err
      @trigger "sharejserror", err, model

{'fraction_non_alphanumeric': 0.14144606874753063, 'fraction_numerical': 0.0150138285262742, 'mean_word_length': 3.2626262626262625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1434588', 'n_tokens_mistral': 815, 'n_tokens_neox': 777, 'n_words': 235}