<commit_before>if Meteor.isServer
    flagHandlers = {}
    FeatureFlag = {}
    FeatureFlag.registerFlagHandler = (identifier, handler) ->
       flagHandlers[identifier] = handler
    FeatureFlag.featureFlag = (flagType) ->
        flags = Meteor.settings.featureFlags || {}
        val = flags[flagType]
        return false if !val?
        for identifier, handler of flagHandlers
            return true if handler(val) == true
        return false

    ###
    # Add a feature flag handler for email domains
    #
    # This would look like  {flag: ['gmail.com']} or {flag: 'gmail.com'}
    ###
    FeatureFlag.registerFlagHandler("email-domains", (val) ->
        return false if !val.email_domains?
        user = Meteor.user()
        return false if !user?
        email = getEmail(user)
        email = [email] if !_.isArray(email)
        return false if !email?
        filterset = if _.isArray(val.email_domains) then val.email_domains else [val.email_domains]
        for e in email
            valid = (item for item in filterset when e.search(item) > 0)
            return true if valid.length > 0
        return false
    )
    ###
    # Add a feature flag for users based on email
    #
    # This would look like {flag: ['<EMAIL>']} or {flag:
    # '<EMAIL>'}
    ###
    FeatureFlag.registerFlagHandler('users', (val) ->
        return false if !val.users?
        user = Meteor.user()
        return false if !user?
        email = getEmail(user)
        email = [email] if !_.isArray(email)
        return false if !email?
        filterset = if _.isArray(val.users) then val.users else [val.users]
        valid = []
        for e in email
            return true if _.contains(filterset, e)
        return false
    )
    ###
    # Simple boolean flag for features
    #
    # This would look like {flag: true} or {flag: false}
    ###
    FeatureFlag.registerFlagHandler('onOff', (val) ->
        return val if val == true or val == false
        return false
    )

    getEmail = (user) ->
        if user.emails?
            _.pluck(user.emails, 'address')
        else if user.services?.google?
            [user.services.google.email]

  Meteor.methods(
      flagsForUser: () ->
        final = {}
        flags = Meteor.settings.featureFlags || {}
        for k, v of flags
            final[k] = FeatureFlag.featureFlag(k)
        return final
  )
  return FeatureFlag<commit_msg>Fix coffeescript indention<commit_after>if Meteor.isServer
    flagHandlers = {}
    FeatureFlag = {}
    FeatureFlag.registerFlagHandler = (identifier, handler) ->
       flagHandlers[identifier] = handler
    FeatureFlag.featureFlag = (flagType) ->
        flags = Meteor.settings.featureFlags || {}
        val = flags[flagType]
        return false if !val?
        for identifier, handler of flagHandlers
            return true if handler(val) == true
        return false

    ###
    # Add a feature flag handler for email domains
    #
    # This would look like  {flag: ['gmail.com']} or {flag: 'gmail.com'}
    ###
    FeatureFlag.registerFlagHandler("email-domains", (val) ->
        return false if !val.email_domains?
        user = Meteor.user()
        return false if !user?
        email = getEmail(user)
        email = [email] if !_.isArray(email)
        return false if !email?
        filterset = if _.isArray(val.email_domains) then val.email_domains else [val.email_domains]
        for e in email
            valid = (item for item in filterset when e.search(item) > 0)
            return true if valid.length > 0
        return false
    )
    ###
    # Add a feature flag for users based on email
    #
    # This would look like {flag: ['<EMAIL>']} or {flag:
    # '<EMAIL>'}
    ###
    FeatureFlag.registerFlagHandler('users', (val) ->
        return false if !val.users?
        user = Meteor.user()
        return false if !user?
        email = getEmail(user)
        email = [email] if !_.isArray(email)
        return false if !email?
        filterset = if _.isArray(val.users) then val.users else [val.users]
        valid = []
        for e in email
            return true if _.contains(filterset, e)
        return false
    )
    ###
    # Simple boolean flag for features
    #
    # This would look like {flag: true} or {flag: false}
    ###
    FeatureFlag.registerFlagHandler('onOff', (val) ->
        return val if val == true or val == false
        return false
    )

    getEmail = (user) ->
        if user.emails?
            _.pluck(user.emails, 'address')
        else if user.services?.google?
            [user.services.google.email]

  Meteor.methods
      flagsForUser: () ->
        final = {}
        flags = Meteor.settings.featureFlags || {}
        for k, v of flags
            final[k] = FeatureFlag.featureFlag(k)
        return final
  return FeatureFlag
{'fraction_non_alphanumeric': 0.10959470636889991, 'fraction_numerical': 0.0008271298593879239, 'mean_word_length': 2.073062261753494, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, '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': '88057', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1376, 'n_words': 417}