Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Unified Diff: sky/examples/data/cities.sky

Issue 876763002: Move city-list data into a separate module (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/examples/city-list/city-data-service.sky ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/data/cities.sky
diff --git a/sky/examples/city-list/city-data-service.sky b/sky/examples/data/cities.sky
similarity index 99%
copy from sky/examples/city-list/city-data-service.sky
copy to sky/examples/data/cities.sky
index cd1855ff1dad44ece97559f9dd538712252e792b..32b8bfedcf694fee62df8880abc21f0d7fe2b522 100644
--- a/sky/examples/city-list/city-data-service.sky
+++ b/sky/examples/data/cities.sky
@@ -4,7 +4,7 @@
// found in the LICENSE file.
-->
<script>
-var cities = [
+module.exports = [
{"name":"New York","state":"New York","population":8363710},
{"name":"Los Angeles","state":"California","population":3833995},
{"name":"Chicago","state":"Illinois","population":2853114},
@@ -5005,44 +5005,4 @@ var cities = [
{"name":"Hartwell","state":"Georgia","population":4298},
{"name":"Newport","state":"North Carolina","population":4298}
];
-
-function CityDataService(cities) {
- this.cities = cities;
-
- // sort by state, city name.
- this.cities.sort(function(a, b) {
- if (a.state != b.state) {
- return a.state < b.state ? -1 : 1;
- }
-
- return a.name < b.name ? -1 : 1;
- });
-}
-
-CityDataService.prototype.get = function(index, count) {
- var self = this;
-
- return new Promise(function(fulfill) {
- var result = [];
- while (count-- > 0) {
- while (index < 0) {
- index += self.cities.length;
- }
- if (index >= self.cities.length)
- index = index % self.cities.length;
-
- result.push(self.cities[index]);
- index++;
- }
-
- fulfill(result);
- });
-}
-
-module.exports = {
- service: new Promise(function(fulfill) {
- fulfill(new CityDataService(cities));
- })
-};
-
</script>
« no previous file with comments | « sky/examples/city-list/city-data-service.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698