Skip to content

Instantly share code, notes, and snippets.

@omichelsen
Last active July 7, 2016 22:18
Show Gist options
  • Save omichelsen/6440fe07d2c378383dc8c96331f62c81 to your computer and use it in GitHub Desktop.
Save omichelsen/6440fe07d2c378383dc8c96331f62c81 to your computer and use it in GitHub Desktop.
Feature flipping data and rules
const data = {
browser: {
name: 'Chrome',
version: '52.4.53.123',
os: 'Mac'
},
env: 'development',
settings: {
audioConference: {
release: '2016-10-23 22:34:12'
}
},
user: {
name: 'Ole',
role: 'Trusted',
profile: {
avatar: ...
}
}
}
const rules = {
user: {
group: /alpha|beta|theta/i
},
browser: {
name: 'Chrome'
},
browser: {
name: ['Chrome', 'Firefox']
},
browser: {
version: function (data) {
return parseInt(data.version) > 42 && parseInt(data.version) < 50;
}
},
settings: {
audioConference: function (data) {
return (new Date()) > data.release;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment